How can I disable all schema (json-ld) except FAQ?

#576577
  • Resolved Matt
    Rank Math free

    I want to use FAQ schema on some webpages, but I dot want to use any other schemas (WebSite, ImageObject, SearchAction etc.). How can I turn off all of them and leave only FAQPage in pages where it is?

Viewing 1 replies (of 1 total)
  • Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention.

    Please try applying the following filter on your site to remove any other schemas generated by Rank Math from your site except FAQ Schema:

    add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
    	if ( isset($data['faqs'] ) && isset($data['WebPage']) ) {
    		$data['faqs'] = [
    			'@type' => 'FAQPage', $data['faqs']
    		];
    		return $data['faqs'];
    	}
    	else{
    		return [];
    	}
    }, 99, 2);

    If the above one doesn’t work for you, you may apply the following filter instead:

    add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
    	unset($data['WebPage']);
    	unset($data['WebSite']);
    	unset($data['ImageObject']);
    	unset($data['primaryImage']);
    	unset($data['publisher']);
    	unset($data['place']);
    	return $data;
    }, 99, 2);

    Here’s how you can add filters/hooks to your WordPress site:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Let us know how it goes. 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 1 replies (of 1 total)

The ticket ‘How can I disable all schema (json-ld) except FAQ?’ is closed to new replies.