WordPress.org

Ready to get started?Download WordPress

Forums

Sub-navigation for child pages (help needed) (5 posts)

  1. NeilC
    Member
    Posted 6 years ago #

    I'm after a script which lists all the child pages of a parent page, but without including them in the same unordered list as the main navigation. At the moment, my navigation script looks as follows;

    <div class="nav clearfix">

      <li <?php if(is_home()){echo 'class="current_page_item"';}?>>" title="Blog">Blog
      <?php wp_list_pages('title_li=&depth=1');?>

    </div>

    The above script tells WordPress to pull up all parent pages in an unordered list and to slot any child pages in a list item next to the relevant parent page list item. I need a separate script that *only* pulls up child pages, and in a 'sub-navigation' style unordered list. I'm working on a tabbed interface, so I need the child pages to also have a 'current_list_item' selector for selected pages.

    I intend to put the sub-navigation further down in the layout from the main navigation - you can see my existing navigation on http://DotNeil.com.

    Any help is much appreciated!

  2. moshu
    Member
    Posted 6 years ago #

    There are many methods to achieve a two-level menu with Pages and sub-Pages... here is one - even if you will not use it as it is, it might give you some ideas for a start :)

  3. NeilC
    Member
    Posted 6 years ago #

    Thanks moshu - I'll give that a look.

  4. NeilC
    Member
    Posted 6 years ago #

    I've had some help from a guy over on WebDeveloper.com, and he's made a script that shows the sub-pages for each of the main tabs (pages). This is great because is covers quite a few of my problems. The script he produced also gives the parent tab of each of the child pages a 'current_page_parent' class, which means that I can give main tabs a different CSS styling for when one of their child pages is selected.

    I'm testing all this on test.dotneil.com, so you should be able to see my problems there.

    However, I'm stuck with WordPress' inability to add child pages to the main page, either home.php, or index.php. Am I missing something, or am right in making the assumption that the WordPress core just doesn't facilitate sub-pages on the main page of the blog? I wanted to add sub-tabs (pages) on my main blog page, including 'Archives' and 'Categories', but WordPress doesn't seem to want me to do this - I just don't get the option to assign child pages to the main page. I only get the option to assign child pages to 'pages'.

    Does anyone know how to get around this? Any help would be much appreciated, I've nearly finished my dream blog!

  5. motherduce
    Member
    Posted 6 years ago #

    Am I missing something, or am right in making the assumption that the WordPress core just doesn't facilitate sub-pages on the main page of the blog?

    You are correct - I think technically every other page is a subpage of the main page.

    In the Parent page option, Main Page (no parent) is the option.

    Alternatively, you could create a new main page (main2), then use the WordPress options to set the main page to the new page (main2) and have subpages?

Topic Closed

This topic has been closed to new replies.

About this Topic