Here's what I am trying to achieve which I am sure is possible.

I have over 3,000 pages in my WordPress install.

From the start, I should have separated a lot of these pages into 'custom pages' but when I started my blog I wasn't aware of the ability or power of custom pages.

So, here's what I am trying to do: move certain pages from a parent URL to custom pages....

For example, my current standard wordpress structure includes pages that have a parent 'holding' URL for 'fruit' and 'vegetables' (see below)



I'd like to create custom page types (using the pods plugin) for both of these 'parent directories' which in my example above are 'fruit' and 'vegetables'.

So, here's my plan....

  1. Create custom page types using pods
  2. Transfer the old pages to their new custom page template

How would I go about this please, or what would the 'best' approach be?


1 Answer 1


There are many ways you can achieve this and it's pretty hard to say which one will be the best.

First part would be to register your CPTs - this will be easy, I guess. So let's say you already have your CPTs registered and these CPTs are called fruit and vegetable.

So the only thing to do now is to convert existing pages to CPTs.

What will we need?

  • IDs of parent pages,
  • ability to run SQL code.

How to do this?

Just run this query:

UPDATE prefix_posts 
SET post_parent = 0, post_type = 'vegetable'
WHERE post_type = 'page' AND post_parent = <VEGETABLE_PAGE_ID>

And the PHP version, because it may be a little bit easier to run it this way:

function convert_children_of_page_to_cpt( $page_slug, $cpt_slug ) {
    global $wpdb;

    $page = get_page_by_path( $page_slug );
    if ( $page ) {
            array( 'post_parent' => 0, 'post_type' => $cpt_slug ),
            array( 'post_parent' => $page->ID, 'post_type' => 'page' )

DISCLAIMER: Of course you should backup your database before doing any of these queries ;)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.