This is a follow-up to my question about mass-updating WordPress posts here:

How can I mass-update/save all WordPress posts and pages?

And it is in relation to the Rank Math SEO plugin:


The plugin is relying on actions in individual post edits/updates to trigger certain things. So the actions aren't applying to posts existing before the plugin was installed unless they are manually updated. With over 1500 posts and several dozen pages, doing this manually isn't feasible.

Note: Using the built-in WordPress mass-edit feature from the post list does not work to trigger these actions.

The remaining problem has to do with the plugin calculating SEO scores for each post based on the content and meta data already there. These scores should be displayed in a column on the post list screen and in the page list screen.

But no scores are showing up for posts and pages there before the plugin was installed because the calculations aren't triggered until a post edit screen is opened for each page or post. This is being generated once the edit screen is opened (not when the post or page is updated -- why the answer from my previous question fixed one problem but not this part).

Once the score is calculated, it's being put into a custom field which -- when the post is saved -- seems to be pulled into the post list screen to show the scores for each post.

The following code from user Gregory from my previous question does handle the post updating:

function update_all_posts() {
    $args = array(
        'post_type' => 'post',
        'numberposts' => -1
    $all_posts = get_posts($args);
    foreach ($all_posts as $single_post){
        $single_post->post_title = $single_post->post_title.'';
        wp_update_post( $single_post );
add_action( 'wp_loaded', 'update_all_posts' );

But because it doesn't open the edit screen for each post, it isn't triggering the calculation. So no score is entered into a custom field before this saves an update.

What I need is some variation on this which would trigger that calculation as if the "edit" action was being called for each one before the update is saved. And I need to work for both pages and posts.

Any help would be greatly appreciated.


  • As far as I can tell, the plugin does not offer a simple way to run these updates in bulk. The score seems to hook into the edit process via ajax. I recommend getting in touch with the plugin author to see if there's a way to accomplish this. – MikeNGarrett Mar 5 at 19:22
  • Thanks. Unfortunately their response has so far been along the lines of "just don't worry about the scores" rather than caring to fix this. So anyone with existing content and SEO data being imported is losing a key editorial feature. I'll keep playing with it and update if we're able to come up with anything here in case anyone else runs into the issue I guess. It's a great plugin in nearly every other way, so it's a real shame. – JHM Mar 5 at 19:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.