$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>plugins - How can I mass-openedit all WordPress posts & pages?|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

plugins - How can I mass-openedit all WordPress posts & pages?

matteradmin8PV0评论

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.

Thanks!

Post a comment

comment list (0)

  1. No comments so far