ThemeShaper Forums » Thematic

[closed]

Including Specific Pages in Menu

(7 posts)
  • Started 9 years ago by EvilEsq
  • Latest reply from ryans213
  • This topic is resolved

Tags:

  1. I want to include a 'Home' page and only specific top level pages in the menu. I've done this in another theme by adding the following statement in the header:

    (show_home='Home'&include=3,4,5,8,9&sort_column=menu_order')

    but can't figure out how to make it work with the array function in the child theme function.

    Can anyone direct me? Thanks in advance!

    Posted 9 years ago #
  2. Hey,

    try this code in your child theme's functions.php:

    function childtheme_menu_args($args)
    {
        $args = array('show_home' => 'Start', 'sort_column' => 'menu_order',
            'menu_class' => 'menu', 'echo' => true, 'include' => '413, 313');
        return $args;
    }
    add_filter('wp_page_menu_args', 'childtheme_menu_args');

    Change the value for include to your needs.

    Cheers,

    Chris

    Posted 9 years ago #
  3. Viola! Works perfectly now. Thank you very much.

    Posted 9 years ago #
  4. How do you include the page and leep the child pages so it opens up in the navigation as well.

    Posted 9 years ago #
  5. Not sure exactly what you mean but look here for more insight on the arguments you can add to this filter

    http://codex.wordpress.org/Template_Tags/wp_page_menu

    -Gene

    Posted 9 years ago #
  6. ryans213
    Member

    The information Chris provided is oh so close to what I want to achieve. Thank you Chris.

    function childtheme_menu_args($args)
    {
    $args = array('show_home' => 'Start', 'sort_column' => 'menu_order',
    'menu_class' => 'menu', 'echo' => true, 'include' => '413, 313');
    return $args;
    }
    add_filter('wp_page_menu_args', 'childtheme_menu_args');

    The problem with this, and I think CRGO alluded to it, how do I account for the child pages for the navigational links that have a sub menu? For example I need the child page for 313 to show up when I roll over it. I'm sure this is something someone has tackled already given the diversity of Thematic themes out there. Any assistance with this will be greatly appreciated. :)

    Posted 9 years ago #
  7. ryans213
    Member

    I still have not resolved this issue unfortunately. :( I looked into arguments and the closest thing I found was the exclude_tree. Really I almost need an include_tree argument. I discovered I am not alone in that wish. My problem isn't getting a navigation up with links, the problem is when there are new pages added. I need to be able to not have the navigation grow as the site demands more pages.

    Here is a Wordpress support post that has as close to a solution as I have found. http://wordpress.org/support/topic/287555

    Here is a workaround. I started with an array of pages IDs I want to include. I loop through that array, displaying each parent page. I then call wp_list_pages again, looking for the child pages, and add them if they exist.

    $page_ids = array(1,2,3);
    foreach($page_ids as $page_id) {
    $page = wp_list_pages("echo=0&title_li=&include=$page_id");
    $submenu = wp_list_pages("echo=0&title_li=&child_of=$page_id&depth=1");
    if($submenu) $page = str_replace("", "

      $submenu
    ", $page);
    echo $page;
    }

    This code is very clunky, and calls the wp_list_pages multiple times, doing what I assume will be multiple database calls. Not very efficient or pretty, IMO. At least it does the trick for now.

    The ideal solution would be to have an "include_tree" parameter for the wp_list_pages function.

    Is there a better way to do it? I also am trying to account for the superfish menu.

    Posted 9 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.