How to Convert a Post to a Page in WordPress (and Vice Versa)

How to Convert a Post to a Page in WordPress (and Vice Versa)

Posts and page in WordPress serve different functions. However with the new way that menus work, that distinction is becoming a little less clear. For sure, you still need a page if you want to create a static landing page for your website, but for other things like navigation items etc, you can use both posts and pages when creating the menus. One of the biggest practical differences I have found between posts and pages, is that posts show up on the front page of your website (provided you don’t have a static page) or the top of your blog. As such, some articles make sense as part of a continuing line of content, and others fare better as standalone pages.

But what if you need to convert a post to a page or vice versa? What if you misjudged and don’t want your content to appear in reverse chronological order on the front of your blog page? The method you choose for making this conversion will depend on how comfortable you are with making a small change to your database as well as the number of times you need to perform this action. Let’s take a look at each method.

Method 1: Simply Copy the HTML

If you don’t want to do anything too complicated, then this might suit you. Here are the steps:

  1. Create a new post/page;
  2. In another tab, open your existing post/page in the WordPress editor;
  3. Click the “Text” tab;
  4. Copy all the generated HTML;
  5. Paste the HTML into the post/page you created in Step 1;
  6. Copy over all the other meta information, excerpts etc and save the new post/page;
  7. Delete the original.

This simply deletes the first and recreates it again as a new post or page.

Problems with this Approach

However, this might not be the ideal way to go about it. To start off with, it’s not a scalable method for changing the post types of a large number of articles. You can do it now and then with a single post or page, but if you have the need to reassign a bunch of articles in bulk to a new post type, you need a more efficient approach.

The second problem is that some articles have a lot of metadata assigned to their ID. By creating a new article and deleting the original, you’re losing all of that and despite shifting the visible metadata from one to another, a lot of information can be erased. Consider the number of plug-ins that store data related to specific entries in the database. They have no idea that you’re re-creating the article elsewhere. So you lose every association that you’ve made in the past, including related articles indexes etc. Is that really something you’re willing to throw away?

For these reasons, it might be more efficient and cleaner to change the post type in the database itself. Follow the steps below. As an example, I’m going to convert the following page into a post:

edit page

Method 2: Make the Change in the Database

To do this, you’ll need to access phpMyAdmin or any other remote database management system. phpMyAdmin is the most common and usually found in most web hosting installations. For example if you’re using cPanel, here’s a screenshot of the phpMyAdmin icon to click on.

phpmyadmin

You should have set up your database name, username, and password when you first configured WordPress. If you don’t have the details, check your wp-config.php file for the information.

Once phpMyAdmin is open, click the “+” sign next to your database and choose the table “wp_posts” as shown below. This will open up the table in the right-hand pane.

wp posts table

Next, we need to write the SQL statement to find our post/page. For this, we need something unique that belongs to the entry. Despite appearances, it might not always be correct to choose the post ID that you find in the edit URL. Sometimes plugins and other changes can make strange things happen and the ID in the database might not always correspond with what WordPress shows you in the URL parameter.

I personally prefer to use a few words of unique content. That way, nothing can go wrong. In my example above, I have the words “some random content” in my page that is unique. So I write the SQL statement:

SELECT * FROM `wp_posts` WHERE `post_content`LIKE '%some random content%'

Open the “SQL” tab on the top of the right hand pane within phpMyAdmin and paste in the SQL query containing your own unique phrase nested within the percentage (%) signs as shown here. Leave the rest of the SQL statement in tact.

write SQL statement

Click “Go” at the bottom right hand corner of the screen. This will bring up the rows that match your query. You need to find the right one by going to the “post_type” column and searching either for “post”, or “page” – depending on whether or not your original article is a post or page. Note that all of the other entries returned by the SQL statement will be revisions or something else.

The next step is simple – if you want to convert a WordPress post to a page, simply double-click the word “post” in the table and replace it with “page”. If you want to do the reverse, simply replace “page” with “post” as shown here:

converting a post to a page

Click outside the table and your changes will be saved. Now all you have to do is reload your original article and the post type should have automatically changed as well. Here’s a screenshot of how my original page is now a post:

post type changed

As you can see, it has the same URL and therefore the same meta-information and everything else. Nothing has changed. The above process is simple enough for you to repeat multiple times without difficulty. So personally, I find Method 2 a superior alternative to Method 1.

Can use for Custom Post Types as Well

There is nothing special about posts or pages that can’t be applied to custom posts types as well. If you want to convert an existing article into a custom post type that you recently created, simply follow the above steps and you get the same result. Be sure to use the correct identifier for the custom post type that you specified when declaring it in the code. So if you’ve already written a bunch of articles and then suddenly decide that you need to re-create all of them within a specific custom post type, don’t go around manually adding and deleting your existing articles one by one. Simply reassign them to the new custom post type within the database!

Keep in mind that it’s important to make sure that the post/page maintains the same URL as before. The last thing you want is for you to lose all your precious backlink juice and Google rank reputation for your articles. That’s difficult to come by. So preserve it in any way you can. If your URL permalink settings don’t permit it, then make use of 301 redirects to let Google know that the page has been permanently moved.

With a little bit of care and forethought, changing from one custom post type to another should be no problem at all.

Leave a Reply

This Website is Hosted by

Powered by RamNode

Disclosure: We receive a compensation from some of the companies whose products or services are presented on our website.