I'm trying to deal with Wordpress 3.0. It's rather cool thing but I can't get on with one problem. For example, I have such menu tree. Menu tree is constructed from pages.
Home
news
video
audio
Blog
About author
Favourite colors
red
blue
green
My car
wheels
tires
The Idea is: main menu consists of root elements: home, blog, my car On the left side I would like to display children elements of current active root element.
For exammple if person is on the "home" page, on the left part he should see:
news
video
audio
If user is on the "Blog" page, he should see:
About author
Favourite colors
red
blue
green
I can't find an API to do that. Can you sugest me please where can I find it?
UPD: @Jason McCreary I've seen I've seen wp_list_pages() and tried it. I din't get how can I use it: Please, see my template for a page:
<?php
/*
Template Name: page_news
* @package WordPress
* @subpackage Twenty_Ten
* @since Twenty Ten 1.0
*/
get_header(); ?>
<h1>page_news</h1>
<h1>Children menu:</h1>
<?php wp_list_pages('echo=0&child_of=8&title_li='); ?>
<div id="container">
<div id="content" role="main">
<?php
/** Get category id by name*/
//$catId = get_category_by_slug('news')->term_id;
query_posts('category_name=news');
get_template_part( 'loop', 'page' );
?>
</div><!-- #content -->
</div><!-- #container -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
See this line of code:
<?php wp_list_pages('echo=0&child_of=8&title_li='); ?>
I do have the page with id=8 (I see it in URL). Page with id=8 has several children. I want to print them, but they are not printed. The output of the function wp_list_pages() is nothing. I don't know why... :(
have you seen wp_list_pages?
http://codex.wordpress.org/Function_Reference/wp_list_pages
look closer on child_of attribute
You can write a filter_hook to accomplish this.
My method: create an additional
start_in
argument forwp_nav_menu
using my custom hook:Next, in your template you just call
wp_nav_menu
with the additionalstart_in
argument containing the ID of the page you want the children off:mac joost's answer is great, but I would add that if you want the parent item to print, then you shouldn't unset the parent, so line 18 needs to be adjusted accordingly:
I've stopped to explore how to output custom part of worpress site taxonomy on the server-side. I just use jquery to copy active taxonomy branch from main menu and paste it to the page container I need.
You can use Breadcrumb navxt plugin. It does exactly what you are looking for and its really great. Breadcrumb NavXT Pugin
I wrote this to print sub-navs of the pages you may be on. If you want to print out the sub-navigation for each of the pages, get the page parent instead of getting the ID. There would be more involved than that, but it's a start.