Custom Schema Markup

#28072
  • Resolved Hugo Balbuena
    Rank Math free

    I see someone open a ticket talking about how to extend the options for custom schema markup. One of your guys provide this code…
    /**
    * 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);

    I just add it to my php function, now whats next? How can I add more information like services by location by Example? Thank you

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

    Thank you for contacting Rank Math today.

    The next step is to use a online schema generator such as this one: https://technicalseo.com/tools/schema-markup-generator/ to generate the schema that you would like to use and pass this to the filter as shown in this example:

    /**
    * 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_singular('listing')){
    	$data['Organization'] = [
    			'@context' => 'https://schema.org',
    			'@type'    => '',
    			'@id'      => '',
    			'name'     => '',
    			'url'      => '',
    			'sameAs'   => '',
    		];
    	return $data;
    	}
    	return [];
    }, 10, 2);

    Looking forward to helping you. Thank you.

    ​​​​​​

    Thank you for the support

    Todd
    Rank Math free

    Hi Hugo,

    We are glad to be of help. We are always here if you need us in the future.

    Hey, if it isn’t too much to ask for – would you mind leaving us a review here?

    https://s.rankmath.com/reviewrm

    It only takes a couple of minutes but helps us tremendously.

    It would mean so much to us.

    Thank you.

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

The ticket ‘Custom Schema Markup’ is closed to new replies.