Bulk Edit WordPress Posts and Pages

Bulk Edit WordPress Posts and Pages

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.

How to Display All Posts or Pages in the “All Posts” or “All Pages” Screens

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 Select Posts or Pages for Bulk Editing

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.

How to Bulk Edit Posts or Pages

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.

https://www.skyverge.com/blog/add-custom-bulk-action/
https://wordpress.org/plugins/custom-bulk-actions/
https://github.com/Seravo/wp-custom-bulk-actions/
http://wpdreamer.com/2012/03/manage-wordpress-posts-using-bulk-edit-and-quick-edit/

Custom Bulk/Quick Edit Plugin

Custom Bulk/Quick Edit Plugin

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.

Custom Field Bulk Editor Plugin

Custom Field Bulk Editor Plugin

You can use the above free plugin to bulk edit custom fields of posts and pages.

Quick Featured Images Plugin

Quick Featured Images Plugin

You can use the above Quick Featured Images Plugin to set and edit featured images in bulk.

WP Bulk Editor Plugin

WP Bulk Editor Plugin

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.

Better Search Replace Plugin

better-search-replace

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.

https://codex.wordpress.org/WordPress_Backups

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.

http://www.wpbeginner.com/beginners-guide/how-to-find-post-category-tag-comments-or-user-id-in-wordpress/

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.

https://www.siteground.com/tutorials/phpmyadmin/phpmyadmin_mysql_query.htm
http://support.hostgator.com/articles/specialized-help/technical/phpmyadmin/how-to-run-sql-queries-in-phpmyadmin

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.

https://codex.wordpress.org/Class_Reference/wpdb

Bulk Edit Posts and Pages on Multiple Sites in Multisite Network

You can bulk edit posts and pages in multiple sites in Multisite Network by developing small WordPress plugin and adding the above custom code in it.

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.

https://codex.wordpress.org/WordPress_Backups

Feel free to share if you have any new ideas to bulk edit posts and pages.

Leave a Reply

Your email address will not be published. Required fields are marked *