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.
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.
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.