WordPress.org

Ready to get started?Download WordPress

Forums

How to move only pages to root with WP in subdirectory (13 posts)

  1. Pieter
    Member
    Posted 1 year ago #

    I have an existing WP in a subdirectory "example.com/blog" plus a static site in the root.
    Now I want to delete that static site from the root and get only my pages from WP in that root, while WP installation and posts stay in that subdirectory /blog.

    I read a lot about moving stuff, but could not find a neat way to do this.
    Thanks in advance for any advice.

  2. jibbius
    Member
    Posted 1 year ago #

    Pages are actually stored in your database, not as files.

    Easy method:
    Setup your new wordpress,
    Copy your database to the new site (there many are tutorials and tools on this. pick your poison). Backupbuddy is pretty good.
    Delete all of the stuff you didn't want to migrate.

    Migrating stuff selectively *can* be done... its just not easy. if you haven't migrated or copied a site before, then I wouldn't be taking on this extra challenge just yet.

  3. Pieter
    Member
    Posted 1 year ago #

    Thanks for your reply jibbius, but maybe my post was not clear.

    It is not about moving, but about splitting the existing site, where only the existing "pages" should now appear in the root and the existing "posts" + WP stay in place in the subdirectory.

    I moved a lot of WP sites in the past btw.

    Thanks.

  4. jibbius
    Member
    Posted 1 year ago #

    Right - so you're actually asking about Permalinks?

    You want 1 site, with:
    http://www.site.com/page-1
    http://www.site.com/page-2
    http://www.site.com/my-other-page
    http://www.site.com/blog/post-1
    http://www.site.com/blog/post-2
    http://www.site.com/blog/another-post
    ?

    To do this, simply:
    - Go to Settings > Permalinks
    - Select "custom structure"
    - Add "/blog/%postname%/" in the box at the end
    (this affects *only* your posts, not your pages)

  5. Pieter
    Member
    Posted 1 year ago #

    Ok, good idea doing that with permalinks, but ...
    The WP installation is already in the /blog directory, so I guess I need to leave the posts as they are and put some code for the "pages" to go up to the root?

  6. jibbius
    Member
    Posted 1 year ago #

    Hmm.
    You can use the steps here: http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory
    Look at the heading "Using a pre-existing subdirectory install".

    How I would do it:
    1. Backup both websites and databases!
    2. Export the Pages from (root) site, using Tools > Export... or any other method
    3. Import the Pages into the (subdirectory) site
    4. Delete the root site (but not the subdirectory site)
    5. Change the url & copy files as described in the link above
    6. Edit index.php as described in the link above
    7. Update the Permalinks page.

    Alternatively:
    1. you can try getting the root website, to use the database that belonged the subdirectory site (then delete the subdirectory).
    2. to do this you just change wp-config.php, and update home + siteurl in wp_options

    Backup everything before you change anything though.

  7. Pieter
    Member
    Posted 1 year ago #

    I think it is still not clear what I meant.
    • The old site in the root will be deleted completely.
    • The one and only site in the subdirectory stays there in /blog with installation and only the posts, while only the "pages" should appear in the root.

    So is it possible to get only the posts in /blog and to get the pages in the root?

  8. esmi
    Forum Moderator
    Posted 1 year ago #

    Yes - if you use a sub-directory install and follow the instructions in Giving WordPress Its Own Directory.

  9. Pieter
    Member
    Posted 1 year ago #

    Thanks esmi.
    I understand the subdirectory install.
    Then when I make new pages they automatically appear in the root and by putting "blog" in the category base permalinks, all posts appear in /blog? Is that right?

  10. esmi
    Forum Moderator
    Posted 1 year ago #

    Bingo! :-)

  11. Pieter
    Member
    Posted 1 year ago #

    Just for the record, putting up the rest of the road I went.

    While the move seamed to work out right, I screwed up by using a script for changing links in the database. Had to use backup to start again :-)
    So I decided to go for the WP installation in root to keep it simple.
    So far so good. Used Velvet-blues-plugin to change links in posts for pics. Ok.

    Then I used the category base /blog. But that appeared to put /blog instead of /category but it is not putting individual posts in /blog like: example.com/blog/individualpost. Which means that old urls to individual posts are changed.
    So I'll have to try to fix that with some htaccess code, catching those mistakes and leading them to the right location.

  12. jedweb
    Member
    Posted 9 months ago #

    Pieter...

    I need to do _exactly_ what you needed to do. Now that you've done it, do you know of a better way?

    It seems like it should be simple. Something like adding '..' to the custom path to get the pages up a level from the subdirectory.

    It seems strange that this should be a convoluted fix.

    Did you learn any easier way?

  13. Pieter
    Member
    Posted 9 months ago #

    jedweb, sorry but lack of time made me leaving this as it is for the time being ...
    Doesn't seem to be simple indeed.
    Hope to solve this later ...

Topic Closed

This topic has been closed to new replies.

About this Topic