How to Convert a Post to a Page in WordPress
How to Convert a Post to a Page in WordPress without Dangerous SQL
The Difference Between Posts and Pages
Posts and pages serve very different purposes in WordPress. When you write a post, it shows up on the front page of your blog, and you can place it into different categories so that your readers can view all posts of a specific category in one place. In addition, it typically has post information displayed near the header. All of this is to indicate that a post is somewhat “ephemeral”. The date of publication is relevant. Users can also comment on posts by default, which means it’s interactive.
A page on the other hand is associated more with “static” content. It’s less time dependent than a post. most themes don’t display the date of publication, since it’s irrelevant. In addition, your viewers normally don’t have the option to comment on pages. For example, why would you need feedback on an “About” page? Or a contact page? It doesn’t make sense.
For this reason, pages are usually placed in menus either at the top of your site, or at the sidebar. Without that, there’s no automatic “link pathway” to pages. With posts, you can reach any given post by merely navigating to the date archives, or the category archives, just simply keep pressing the “Next” or “Forward” buttons on your homepage to scroll through all posts. But pages need to be linked to specifically, or else they get lost in your content.
Why Convert a Post to a Page?
It’s very easy to accidentally create a post instead of a page. For one thing, posts are a lot more common than pages, so most people just create a post by default. I’ve done it myself several times! And the WordPress editor treats them both as exactly the same unless you have some specific customizations that are immediately visible.
Often you won’t even notice the difference until after you’ve published the post and you see that it has a comments section! Or that it shows up on your site blog when that simply doesn’t make sense if you’ve just published a “Terms and Conditions” post for instance!
Of course, you can just create a new page, copy over the content of the post, delete the original post, re-create the URL, and publish the new page. But personally, I would feel uncomfortable with such a maneuver. I don’t like the idea of deleting a post and recreating a page with the same content.
So, it’s much more elegant to just convert the post to a page. In this tutorial, I’ll show you how that’s done. Normally, tutorials on how to do this recommend updating your database via SQL. But this can be dangerous if something goes wrong. So my tutorial will only use “safe” SQL for searching, but won’t actually update the database.
For updating we’ll use the regular phpMyAdmin GUI, making it impossible to break your site.
Warning: Nonetheless, before doing any of these, make sure you backup your databases first!
Using phpMyAdmin to Convert a Post to a Page in WordPress
Not everyone wants to install a WordPress plugin and add to their maintenance headaches. Especially when it’s just a “one off” job like converting a post to a page. So we’re doing to go in and do it through the backend.
Step 1: Open phpMyAdmin from cPanel
Log into your web hosting provider’s cPanel and search for the words “phpMyAdmin”. This is a ubiquitous backend database tool for MySQL installed on every cPanel implementation that I’ve seen:
This will bring up the login screen for the databases. You should have received this in your welcome mail when you first set up your hosting account.
Step 2: Locate your Database from within phpMyAdmin
If you have several WordPress installations, or have other databases like the ones created by Joomla etc, then you’ll have a separate database for each of these installations. You’ll need to find the right one for your current WordPress site.
One way to do this is by examining your wp-config.php file in your WordPress installation folder and getting the database name from the “DB_NAME” variable like this:
Another way is to expand each database by clicking the plus (+) sign and searching for signs of plugins that you’ve installed only on the one you want. Either way, make sure that you get the correct database before proceeding further!
Step 3: Open the “posts” Table
Normally the table you want is called “wp_posts”. But for security reasons, many WordPress sites rename the default prefix of their tables to something other than “wp”. Certain security plugins do this for you as well. So find the table ending with “_posts” and click it.
This will expand the table and bring up all the rows – each of which is either a post, a page, or a revision, or some other type of custom post type.
Step 4: Find the Original ID of the Post you Want
This can be a two-step process. The easiest way to find the ID of your post is to look at its “Edit URL”. This is the URL you see in the address bar when editing the post in the WordPress editor.
Alternatively, hover your mouse over the “Edit” for the post and you’ll see it in the status bar like this:
Here, the ID of my test post is 693. Now that you have the post ID, move to step 4.
Step 5: Locate the Row using the Post ID
This is the only SQL you need to use, and it’s “safe” because it doesn’t update, or delete anything from the backend. First, while viewing the correct “posts” table we identified in Step 3, click the SQL tab as shown here:
Now type in the following SQL command in the editor like demonstrated:
SELECT * FROM `[table name]` WHERE `ID` = [post ID]
Replace [table name] with the table name you got in Step 3, and [post_ID]with the post ID you isolated in Step 4.
This should filter the rows and show you the post in question as in this screenshot:
Sometimes, the posts table stores records for revisions or other things. So just scroll to the right of the row to make sure that the “post_parent” column shows “0” like this:
If not, then note the ID of the post parent and repeat the above SQL query with the post parent ID. This time, the row you get should be the original post that you want to change.
Step 6: Change the Post Type to “Page”
Click the “Edit” button on the left of the row as shown in the screenshot in Step 5. This will open the record for editing. Scroll down till you find the field labeled “post_type”, and replace the value “post” with “page” as shown here:
Now click the button called “Go” on the bottom right. The query will process and you’re done! Your post is now a page. Visit the URL and confirm that there’s no comment box. Technically, we could have accomplished the update with another SQL query, but I like to avoid making updates or changes to my backend databases via manual SQL. If something goes wrong, it’ll break my site.
So this is a safe way to convert a post to a page in WordPress. I’ve used it many times, and I hope you find it as useful as I have!