如何显示菜单树的一部分? [英] how to display part of a menu tree?
问题描述
我正在尝试处理Wordpress 3.0.这是一件很酷的事情,但我无法解决一个问题.例如,我有这样的菜单树.菜单树是由页面构成的.
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
我找不到执行此操作的API.你能给我点个手势吗?我在哪里可以找到它?
I can't find an API to do that. Can you sugest me please where can I find it?
UPD: @杰森·麦克雷里(Jason McCreary) 我已经看过wp_list_pages()并尝试过.我不知道如何使用它: 请,请参阅我的模板页面:
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(); ?>
请参阅以下代码行:
<?php wp_list_pages('echo=0&child_of=8&title_li='); ?>
我确实有id = 8的页面(我在URL中看到它). id = 8的页面有多个子代. 我想打印它们,但不打印.函数 wp_list_pages()的输出为空. 我不知道为什么...:(
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... :(
推荐答案
我已经停止探索如何在服务器端输出worpress网站分类法的自定义部分.我只是使用jquery从主菜单复制活动分类分支并将其粘贴到我需要的页面容器中.
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.
这篇关于如何显示菜单树的一部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!