Custom Snippet

#20535
  • Resolved Sprouts
    Rank Math free

    Hello,

    Our company would like to use Rank Math’s Rich Snippet feature to create a Schema for our physical storefront locations. In particular, we are looking for a Local Store(Grocery) Schema. Currently, there is nothing like that in the snippets configurations. Is there a way we can create a Custom Schema in Rank Math to accomplish this or is Rank Math able to provide us with a the code modifications to accomplish this? We are also looking for a FAQ Schema.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hello,

    Thank you for contacting Rank Math today.

    The grocery store schema is actually available under local business schema. Please navigate to Rank Math > Titles & Meta > Local SEO > Business Type and search for Grocery store.
    To be able to create the FAQ schema, you can use the following online generator tool:
    https://saijogeorge.com/json-ld-schema-generator/faq/?utm_campaign=Rank+Math
    Next, you can use the following filter to add this schema type to your site:

    /**
     * Collect data to output in JSON-LD.
     *
     * @param array  $unsigned An array of data to output in json-ld.
     * @param JsonLD $unsigned JsonLD instance.
     */
    add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
    	return [];
    }, 10, 2);

    Looking forward to helping you. Thank you.

    ​​​​​​

    Hey Michael, thats great for the FAQ Option thank you. The Local SEO option won’t work for us unfortunately. Each one of our Stores is a Post in our Stores CPT and would like to have Rich Snippets for Grocery Stores so that each Store can have a Grocery Store Schema. I know how and have already created a Schema for the Stores, but I wanted to see if Rank Math had a solution where I wouldnt have to create hundreds of these Schemas manually.

    • This reply was modified 4 years, 4 months ago by Sprouts.

    Hi There,

    Thanks for the follow-up and the feedback, really appreciate.

    I’m going forward the same to the dev for further consideration.

    Have a good one.

    One more question. Is this FAQ snippet you included going in our theme’s Function.php file or somewhere else?

    Hello,

    Thank you for contacting Rank Math today.

    Yes this code should be added to your theme’s functions.php file.

    Looking forward to helping you. Thank you.

    ​​​​​​

    I added this to my theme’s function.php file but I’m not seeing it show up on my site. Where specifically should I see this appear?

    Hello,

    Thank you for contacting Rank Math today.

    As I mentioned earlier, this schema is not available in Rank Math and you have to use the following online generator to create the required schema: https://saijogeorge.com/json-ld-schema-generator/faq/?utm_campaign=Rank+Math

    Next, you can add the generated schema data on your site using the filter we discussed before or you can directly inject the schema data using the headers and footers plugin:
    https://wordpress.org/plugins/insert-headers-and-footers/

    Here is an example that should guide you on how the code should look in the end:

    /**
     * Collect data to output in JSON-LD.
     *
     * @param array  $unsigned An array of data to output in json-ld.
     * @param JsonLD $unsigned JsonLD instance.
     */
    add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
    	if(is_page('234')){ //target certain page using its id
    	$data = [
    			'@context'       => 'https://schema.org',
    			'@type'          => 'FAQPage',
    			'mainEntity'     => [
    				'@type' => 'Question',
    				'name'  => 'Question one',
    				'acceptedAnswer' => [
    					'@type'  => 'Answer',
    					'text'   => 'Answer one',
    				],
    			],
    		    'mainEntity'     => [
    				'@type' => 'Question',
    				'name'  => 'Question Two',
    				'acceptedAnswer' => [
    					'@type'  => 'Answer',
    					'text'   => 'Answer Two',
    				],
    			],
    		];
    	return $data;
    	}
    	return [];
    }, 10, 2);

    You may need to get in touch with your developer to help in adding this code.

    Looking forward to helping you. Thank you.

    ​​​​​​

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 7 replies - 1 through 7 (of 7 total)

The ticket ‘Custom Snippet’ is closed to new replies.