In this tutorial we are going to see how to bulk edit WordPress posts and pages.
By default WordPress allows us to edit posts and pages in bulk but for that we have to display list of all the posts and pages on “All Posts” and “All Pages” screens respectively as described below so that we can bulk edit it.
How to Display All Posts or Pages in the “All Posts” or “All Pages” Screens
To display all posts or pages just visit the “All Posts” or “All Pages” screens and click on the “Screen Options” tab then in the displayed form add the maximum number of items like 999 in the field “Number of items per page:” and click save the changes on clicking the Apply button as shown in the following screenshot.
Make sure to select the checkboxes of options like Author, Categories, Tags etc. in the above screen which you want to bulk edit.
How to Select Posts or Pages for Bulk Editing
You can either choose to edit selected posts or pages or select all of them for bulk editing by checking appropriate checkbox on “All Posts” or “All Pages” screens, then select the Edit option from the action drop down and click on the Apply button to edit them as displayed in the attached screenshot.
How to Bulk Edit WordPress Posts and Pages
On click Apply button you will get the following screen where you can edit various options of selected posts or pages and click on the Update button to save the changes.
Bulk Editing Posts and Pages Default Elements
By default you can bulk edit following elements of posts and pages.
You can bulk edit post categories.
You can bulk edit post tags.
You can bulk edit author.
You can bulk edit comments.
You can bulk edit status.
You can bulk edit post format.
You can bulk edit post pings.
You can bulk edit post sticky.
You can bulk edit page parent.
You can bulk edit page template.
Note: Categories and Tags can be ADDED in bulk to a set of Posts, but it is not possible to CHANGE, or DELETE, a Category or Tag, for those Posts.
Bulk Editing Posts and Pages Non Default Elements
You can bulk edit default elements easily but what if you also want to bulk edit other non default post or pages elements?
Currently WordPress doesn’t allow you to add custom bulk actions. It’s written on this codex page as following.
The filter doesn’t currently (WP 3.3) allow you to add custom bulk actions. See https://core.trac.wordpress.org/ticket/16031
But you can add custom bulk actions using the following solutions.
Developing Custom Code to Add Bulk Options
You can refer the solutions posted on the following pages to create custom bulk actions.
Using this “Custom Bulk/Quick Edit” plugin, you can achieve the following bulk editing operatiions which is not possible by default.
You can bulk edit post titles.
You can bulk edit page titles.
You can bulk edit posts excerpts.
You can bulk edit posts categories.
You can bulk edit posts tags.
You can use the above free plugin to bulk edit custom fields of posts and pages.
You can use the above Quick Featured Images Plugin to set and edit featured images in bulk.
The above premium bulk editor plugin allows you to bulk edit various post and page elements by exporting excel file containing its data which you can edit using find and replace feature of excel and import the edited excel file again to update the changes on site.
The above free Better Search Replace Plugin is so powerful and advanced plugin that allows you search in the WordPress database and replace it with other values.
The above plugin is an advanced plugin to use for inexperienced users so if it used carelessly can cause unexpected issues therefore i recommend to take backup of your database as described on the following page before using it.
Developing Custom SQL Query to Bulk Edit Posts and Pages
You can also bulk edit posts and pages by developing and executing custom SQL query in your WordPress database.
For example, if you want to change old post author to new on for all posts then you can execute the following SQL query in your WordPress database by replacing OLD_AUTHOR_ID with the old user/author id and NEW_AUTHOR_ID with the new user/author id.
UPDATE wp_posts SET post_author=NEW_AUTHOR_ID WHERE post_author=OLD_AUTHOR_ID and post_type='post';
You can find user/author id as described on the following post.
After executing this SQL query in your WordPress database, all posts from the old author now appears to have been written by the new author.
Find information on the following pages about how to execute SQL query in the database.
You can change any WordPress fields in the WordPress database using the SQL query. See WordPress database description here https://codex.wordpress.org/Database_Description
Developing Custom Code to Bulk Edit Posts and Pages
If you are not comfortable with executing SQL query in database then you can also execute it by temporary adding the following custom code in the functions.php file of your theme.
Do not forget to change the variable values of NEW_AUTHOR_ID and OLD_AUTHOR_ID in the following code.
$NEW_AUTHOR_ID = 1; $OLD_AUTHOR_ID = 25; global $wpdb; $wpdb->query( " UPDATE $wpdb->posts SET post_author = $NEW_AUTHOR_ID WHERE post_author = $OLD_AUTHOR_ID AND post_type='post' " );
You will find information on the following page about how to execute SQL query from code in WordPress.
Bulk Edit Posts and Pages on Multiple Sites in Multisite Network
You should temporary either network activate the developed plugin or add it in the mu-plugins directory to execute the code.
You can also achieve this by adding the above code in the functions.php file of the theme but in this case you have to make sure to active that theme on every site of the multisite network which is not feasible.
Please before executing any custom code, take backup of your database as described on the following page so that it can be recovered if anything goes wrong.
Feel free to share if you have any new ideas to bulk edit posts and pages.