-
Hi, I have enabled Schema (Structured Data) and selected ‘person’ for the post type ‘doctor’ and ‘service’ for post type ‘services’.
The schema is loading on the standard pages, but not on these two custom post types.
I have added the code below to the functions file of the theme but it made no difference.
How do I get the schema to show on these two custom post types? thanks
/**
* Allow developer to default Schema type (Snippet type) by post type.
*
* @param string $type Snippet Type.
* @param string $post_type Post type name.
*
*/
add_filter( ‘rank_math/settings/snippet/type’, function( $type, $post_type ) {
return $type;
}, 10, 2 );add_filter(‘rank_math/settings/snippet/type’, function ($type, $post_type) {
if (‘doctor’ === $post_type) {
$type = ‘person’; // Schema type.
}
return $type;
}, 10, 2);
The ticket ‘rank-math-schema missing from custom posts’ is closed to new replies.