WordPress.org

Ready to get started?Download WordPress

Forums

Child pages without parent slug on uri (10 posts)

  1. xaviersarrate
    Member
    Posted 1 year ago #

    In a new project our client wants to have child pages without parent slug on uri.

    This is an hypothetical structure:
    - Home : /
    --- About us : /about-us
    ------ Our company : /about-us/our-company
    ------ People : /people <---- but this page is child of "about-us"
    --------- Peter : /people/peter <---- idem

    Is this possible on WP? It's important to show menus correctly (current ancestor, subsection navigation, etc...)

  2. bcworkz
    Member
    Posted 1 year ago #

    This can be done with the Rewrite API. Navigation will remain an issue, but it can usually be addressed with template hacks and function filters.

  3. xaviersarrate
    Member
    Posted 1 year ago #

    Could you be a little more specific? I would appreciate it

  4. bcworkz
    Member
    Posted 1 year ago #

    It's hard to be specific without a specific situation to address. Combine that with I don't have specific experience with the Rewrite API myself, though I do understand the concept well enough. I'll do the best i can.

    Using your hypothetical example, your goal is to use the API so that an entry ends up in the .htaccess file that modifies any url with "/people" as the first folder argument to be made into "/about-us/people" behind the scenes (meaning the url in the address bar does not change) with anything that comes afterwards to remain as-is.

    You could maybe do this with an .htaccess entry alone. The reason for using the API is the query variables get handled properly, but in this case, I believe this will happen in either case.

    That leaves the navigation issues, which is partly dependent on the specific templates involved, but shouldn't be that difficult to alter. The other navigation issue is WP functions that output links. In this case, there is typically a filter you can hook to take out the unnecessary "/about-us" url element, or there is a variant function that returns a link instead of echoing it, giving you the opportunity once again to remove the "/about-us" element.

  5. catacaustic
    Member
    Posted 1 year ago #

    If they are only worried about the URL's but want the navigation to remain the same, just don't set a parent page for any page, and set up your own menu for the navigation with the proper hierarchy. That's all it takes. :)

  6. xaviersarrate
    Member
    Posted 1 year ago #

    Navigation and url are important. Website will be very huge, with a lot of dynamically generated pages (not real WP pages, generated via API rewrite and CF with ACF). A manual navigation is always be possible, but in this case will be very hard to maintain.

    We are talking also with WPML people about translation links with dynamically generated pages (current WPML doesn't support it). Perhaps WP is not the CMS for this project =(

  7. catacaustic
    Member
    Posted 1 year ago #

    You can always program your own custom walker class/classes to set up a custom-built menu for your system. There's more explained here: http://codex.wordpress.org/Function_Reference/wp_nav_menu#Using_a_Custom_Walker_Function

  8. xaviersarrate
    Member
    Posted 1 year ago #

    Yes, that was the first idea we had, but we hoped someone had something simpler = (

  9. catacaustic
    Member
    Posted 1 year ago #

    Having something "simpler" sounds like it's not going to work for you. You've already said that you're having a site with dynamically generated pages, API rewrites and more, but developing a walker class to get the navigation menu right is a worry?

    I'm sure that you understand that a lot of the time "something simple" and "must do what we need it do" just don't go together. This is one of those cases. You can't have a dynamic site like that and not have a custom menu without a few hassles. If you think that it's going to be hard in WordPress I'd almost challenge you to do the same in another CMS like Druapl or Joomla! as those are a whole other degree or worse trying to do things like this.

  10. xaviersarrate
    Member
    Posted 1 year ago #

    It's not about walker class. It's just this damn project...

    Really, thank you for your help

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.