Changing the schema type for all the posts.

#53670
  • Resolved Lifetimo
    Rank Math free

    For a long type, I had set the schema type for my custom post ‘deal’ as ‘Software/Application’ on RankMath. but later after 5-6 months, I noticed that this was the wrong schema type for my post. So, I changed the schema type to ‘Article’ now.

    But when I checked, I noticed that only new post is getting this new schema type by default. For past 200+ posts, those are still showing ‘Software/Application’ as schema type.

    How to change the old schema type on past/existing posts with new schema type ?

    I know that I can change it by manually editing each post and change the schema type for old posts. But that it too tedious and manual work. There must be some each way to change the default schema type for all the articles with one click or one command.

    Kindly help me with this.

    Other question –

    What should be the general default schema type which supports reviews ( star ratings ) and ‘tables’ creating using other third party plugins? Those third party plugins have their own schema for ratings and tables.. but since I use RankMath, what should be my default settings for those posts?

    They say that they are compatible with all SEO plugins like Yoast, SEOPress.. etc.

    Thank you.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Alberto
    Rank Math business

    Hello,

    Thanks for the question.

    The rich snippet values for each post are saved as custom field values on your database and thus you can create a custom loop to step through all the posts on your post type and update the rich snippet fields. For example, the rich snippet name is saved in the “rank_math_rich_snippet” custom field and thus you could make use of the following snippet to update all the values on your posts but as I mentioned earlier, for the schema to be complete you will need to update each post with unique values for each entity on the schema.

    function update_custom_data(){
        $args = array(
            'post_type' => 'post', // assign the post type
            'post_status' => 'publish', // Only the posts that are published
            'posts_per_page'   => -1 // Get every post
        );
        $posts = get_posts($args);
        foreach ( $posts as $post ) {
            // Run a loop and update every meta data
            update_post_meta( $post->ID, 'rank_math_rich_snippet', 'new_rich_snippet_name' );
        }
    }
    // Hook into init action and run our function
    add_action('init','update_custom_data');

    To answer your second question, you could use the Schema that best fits your article and if you are not sure, use the Article schema which is fine for almost every situation.

    I hope this info helps. Thank you.

    I don’t see rank_math_rich_snippet value for the article schema type.

    Also, please tell me the exact code which I should paste in functions.php if I want to change existing schema type ‘Software Application’ to new schema type ‘Article’

    Is this right –

    function update_custom_data(){
    $args = array(
    ‘post_type’ => ‘post’, // assign the post type
    ‘post_status’ => ‘publish’, // Only the posts that are published
    ‘posts_per_page’ => -1 // Get every post
    );
    $posts = get_posts($args);
    foreach ( $posts as $post ) {
    // Run a loop and update every meta data
    update_post_meta( $post->ID, ‘rank_math_rich_snippet’, ‘article’ );
    }
    }
    // Hook into init action and run our function
    add_action(‘init’,’update_custom_data’);

    What if I want to set the new schema type to ‘none’ means no schema from RankMath.

    So should I add this in functions.php

    function update_custom_data(){
    $args = array(
    ‘post_type’ => ‘post’, // assign the post type
    ‘post_status’ => ‘publish’, // Only the posts that are published
    ‘posts_per_page’ => -1 // Get every post
    );
    $posts = get_posts($args);
    foreach ( $posts as $post ) {
    // Run a loop and update every meta data
    update_post_meta( $post->ID, ‘rank_math_rich_snippet’, ‘none’ );
    }
    }
    // Hook into init action and run our function
    add_action(‘init’,’update_custom_data’);

    Are both these codes correct to convert from ‘Software/application’ schema type to ‘Article’ or ‘None’ ?

    I also read something related here – https://rankmath.com/kb/how-to-fix-review-schema-errors/

    but I don’t see any such options any more in the RankMath plugin. 🙁

    It’s been more than 34 hours .. but no response yet.

    Does it need heavy research from your side?

    Waiting for the support response.

    Thanks.

    Todd
    Rank Math free

    Hello,

    That option is only available if you used a really old version of Rank Math when we had the review Schema.

    We are sorry but there is no option to mass edit Schema. If you are familiar with code, you can use the above code my colleague provided.

    But, we do not offer support for features that Rank Math doesn’t have built in like an option to bulk edit Schema.

    Hope that helps.

    That worked

    Todd
    Rank Math free

    Hello,

    We are glad to hear it is all sorted now.

    If you need help with anything else, please open a new support ticket here so we can help:

    https://support.rankmath.com

    We are always here for assistance.

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

The ticket ‘Changing the schema type for all the posts.’ is closed to new replies.