3

I'm using a free SEO plugin for WordPress called Rank Math - https://wordpress.org/plugins/seo-by-rank-math/

Overall, I like it a lot. But it has some problems for users with existing WP sites who are importing data from another plugin like Yoast.

Rank Math is relying on individual posts and pages to be edited (not using WP's bulk quick edit feature, but opening each post and re-saving them one-by-one).

This happens with author sitemaps for example. An author's page is only added to the sitemap if I manually open and re-save one of their posts and then re-save the sitemap settings. It doesn't find and add existing authors otherwise.

Is there any way to simulate clicking the "update" button for all posts and pages without changing any actual content in a circumstance like this?

Thanks.

1

Add to your functions.php file, but dont forget to take it off after use it !!!!!

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' );

PS : BE SURE TO MAKE A DATABASE BACKUP BEFORE EXECUTE !!!

  • Thanks. But as I mentioned in my question, the built-in bulk quick edit feature in WordPress does not work for this. It doesn't trigger any of the necessary actions from the plugin, like the rank calculation. It has to be triggered by the update button on every individual post and page. – JHM Mar 5 at 16:02
  • sorry, didn't read enough ;) i've updated my answear with a function to load ! ( load one time, and then take of ;-) ) – Gregory Mar 5 at 16:10
  • Well, partial success! It did pull most of the authors into the author sitemap. For some reason it missed 5, but I'll manually catch those. It did not, unfortunately, trigger the score calculation for each post. – JHM Mar 5 at 16:17
  • I think the missing 5 had to do with it being 1500 posts. It was loading for a while then crashed. I'll have to run something again for the score calculations, so for future reference, is there a way something like this could be run in batches so it doesn't cause that crash? – JHM Mar 5 at 16:25
  • for this, you should have a look around of php_max_execution_time ! (or run it localy ). – Gregory Mar 5 at 16:29

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.