I currently run a website with WordPress. I'm redesigning my current website with a new theme and changes of some plugins and urls.

Currently I made a total site copy and installed the new theme and started editing this version on a temporary url.

The problem is: I come from the sahifa theme which creates some extra fields and settings per post / page / media which isn't used by my new theme (generatepress).

How can I copy all posts / pages / media and their settings to a new wordpress installation without copying all 'junk' created by the sahifa theme?


That would involve looping through all posts of all types and then delete the extra fields per post. You could run the following code once in your new theme:

$args = array ('post_type' => 'any', 'posts_per_page'=>-1)

$query = new WP_Query ($args);

if ( $query->have_posts() ) {
    while ( $query->have_posts() ) {
        // delete unwanted fields of $post

The delete action depends on what the old theme is generating, but will typically involve calls to delete_post_meta.

Don't do any mass deleting without backing up first.

| improve this answer | |

One of the easiest ways to migrate your posts, pages and media is to use the export tool to generate an XML file. With that, you can choose what content you specifically want to export.

  • Login to your website
  • Go to your admin dashboard
  • In the left admin sidebar, go to Tools and then Export
  • Choose the content your want to export
  • Then click the Export Button

Then, you would go to your main site and go to the Tools Section again but this time, choose the Import Option. You will need to install the WordPress Importer Plugin and then run the Importer. Upload the XML file and follow the prompts.

Since you mentioned you were also looking to change the URL's, you'll need to either run some SQL commands via phpMyAdmin or use a WordPress Plugin called Better Search and Replace to change the URL's.

Another option is to use the Duplicator Plugin which will also give you migration capabilities as well as choosing what to export from the files and database. The Duplicator Plugin also handles the URL changes for you.

Hopefully this helps.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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