WordPress.org

Ready to get started?Download WordPress

Forums

How to create this permalink structure? (3 posts)

  1. nyladenise
    Member
    Posted 9 months ago #

    For my permalink structure, I currently have the "Post name" button selected, where URLs are displayed as mysite.com/postname.

    The site I am building has parent pages with child pages. I noticed that if I type in a child page's URL, I am automatically taken to the page, without me having to reference the parent page. (So mysite.com/child will automatically direct me to mysite.com/parent/child). This is good. This is what I want.

    I also have a blog section on the site. Right now, all of my post URLs look like mysite.com/postname ... which of course is what I am telling it to do with my permalink setting. HOWEVER, for the blog content only, I want "/blog" to precede each post (mysite.com/blog/postname).

    I can't seem to make both of these work. I tried using a custom Permalink setting: /blog//%postname%/ and this worked for my blog content BUT then I discovered that it breaks those direct links for my child pages... I can no longer access mysite.com/child. Doing that gives me a 404 page. Instead I would have to use the full link mysite.com/parent/child.

    So. Seems I can only have one or the other, but I need both. I know there has to be a way. Can anybody guide me on how I can achieve this?

  2. blogjunkie
    Member
    Posted 9 months ago #

    Not sure if WordPress will work like you want it to but try these hacks:

    1. Change the permalink structure to /blog/%postname%/(1 slash in between blog and %postname. Now create a set of new parent and child pages. Try example.com/child again. I suspect that you changed the permalinks *after* creating the parent child pages so WordPress doesn't know what the canonical URL is.

    2. Use the Redirection plugin for your child pages. Be aware though that this causes a performance hit on your site.

    3. Use a .htaccess redirect for your child pages. This is the manual version of option #2 above but doesn't give you a performance hit because it doesn't use any WordPress functions at all. See this tutorial: http://www.javascriptkit.com/howto/htaccess7.shtml

    Good luck

  3. nyladenise
    Member
    Posted 9 months ago #

    Thanks so much for your input. I am actually already using Redirection plugin and it does make things easier. Though I am probably going to move to my htaccess file at some point.

    I was hoping there was a way to do this using some type of global rule or quick editing of my functions.php instead of me having to manually redirect each page... which is what it sounds like I will have to do anyway. Unless I'm missing something. Oh well.

    Thanks again, appreciate you taking the time to respond. :-)

Reply

You must log in to post.

About this Topic