rank-math-schema missing from custom posts

#409469
  • Resolved Deb Shaw
    Rank Math free

    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);

Viewing 5 replies - 1 through 5 (of 5 total)
  • Prabhat
    Rank Math agency

    Hello,

    Thank you for contacting the support and we regret the inconvenience caused.

    Could you confirm if you’ve set those Schemas from Rank Math > Titles & Meta > Doctor/Services? If yes, it would not work as each Person/Service has different properties and thus they cannot be declared globally.

    Please set the global settings to Article and add the Schema individually on each post of those CPTs and see if that helps.

    You can remove the codes that you’ve added.

    Please let us know how that goes.

    Thank you.

    Thanks – that seems to have sorted it…

    Can you help me understand – why is there a section to select the type in the dashboard but this does not work on the custom post types with out editing them manually?

    Thanks…

    Hello,

    The Person Schema gets applied to the posts but you have to edit and save it so it can fetch the details from the post and convert it into the Schema-ready content. And for the Service Schema, you have to add the Service Type in the Schema to apply it. That’s why even after selecting it from the default Schema settings, you still have to edit the post, edit the Schema and save it, and update the post to apply the Schema.

    Hope this helps. Let us know if you need any other assistance.

    Great thanks

    Hello,

    Glad that helped.

    Please feel free to reach out to us again in case you need any other assistance.

    We are here to help.

    Thank you.

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

The ticket ‘rank-math-schema missing from custom posts’ is closed to new replies.