Change schema type in bulk

  • Hi,

    I have over 40k posts. How can I change their schema type to video for all of them at once?



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

    Thank you for contacting Rank Math today.

    You can set the default rich snippet type for your posts to video via Rank Math > Titles & Meta > Posts but is it not possible to update all the posts at once since unique values have to be set for each post.
    This rich snippet requires the following fields that must possess unique values for the schema to be valid: Content URL, Embed URL, Duration & Views.

    I hope this info helps. Thank you.


    I have all these values. Is there any script or snippet I could use to switch the schema?

    Hi Tony,

    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

    I hope this info helps. Thank you.


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

The ticket ‘Change schema type in bulk’ is closed to new replies.