Changing Schema on Custom Post Type Does Not Update Old Posts

#28652
  • Resolved Gareth Daine
    Rank Math free

    Hey,

    When I update the ‘Rich Snippet Type’ for a custom post type under the global ‘Rank Math’ >> ‘Titles & Meta’ >> ‘Post Type Name’ >> ‘Rich Snippet Type’ and then save, it does not update all of the older posts.

    Is there a way to do this?

    Cheers

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

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    This option will only work when creating new posts since the old data is already saved in the database. You will have to open each of the old posts and manually change the schema type.

    Looking forward to helping you. Thank you.

    ​​​​​​​

    Wow! OK, great. This would be a useful feature to include in the tools section, as I can imagine people with thousands of posts would get pretty frustrated.

    Is there an easier way at present for editing this in the database?

    Cheers

    Hi there,

    Thanks for getting back to us.

    All the schema data is saved in the postmeta table of your database but each rich snippet type has unique fields.
    If you are up to the task you can create a query to fetch all your posts and update the meta values.

    I hope this info helps. Thank you.

    Sorted it. Thanks.

    Here is the query for others who may need to do this:

    UPDATE wp_postmeta SET meta_value='article' WHERE meta_key='rank_math_rich_snippet' AND meta_value='product';

    As I say, it would be great if this feature was included in tools.

    That said, I am getting this now on articles:

    url false (The value provided for logo.url must be a valid URL.)

    When testing with the Structured Data testing tool.

    Hi there,

    Thanks for getting back to us.

    Updating the rich snippet type is not sufficient since the rest of the article schema data does not exist.
    You will need to register the rest of the schema data for the article snippet by hooking into the following filter:

    /**
     * Filter to Short-circuit Schema if a 3rd party is interested in generating their own data.
     * Replace $schmea_type with schema name like article, review, etc.
     * @param array $entity Snippet Data
     * @return array
     */
    add_filter( "rank_math/snippet/rich_snippet_{$schema_type}", function( $entity ) {
     return $entity;
    });

    The required entity data is shown below:

    
    			'@context'         => 'https://schema.org',
    			'@type'            => '',
    			'headline'         => '',
    			'description'      => '',
    			'datePublished'    => '',
    			'dateModified'     => '',
    			'publisher'        => '',
    			'mainEntityOfPage' => [
    				'@type' => 'WebPage',
    				'@id'   => '',
    			],
    			'author'           => [
    				'@type' => 'Person',
    				'name'  => '',
    			],
    		

    I hope this info helps.

    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 6 replies - 1 through 6 (of 6 total)

The ticket ‘Changing Schema on Custom Post Type Does Not Update Old Posts’ is closed to new replies.