English 中文(简体)
WordPress Menus - Don t show Sub-Pages
原标题:WordPress Menus - Don t Show Sub-Pages
  • 时间:2011-10-29 02:29:52
  •  标签:
  • wordpress

I ve利用Word >、Appearance >、Mendu备选方案,创建了一个习俗方菜单。 这里的结构是:

About Us
Our Leadership Team
    Name #1
    Name #2
    Name #3
Our Staff and Advisory Board
    Name #1
    Name #2
    Name #3
    Name #4

菜单在我想要的网页上显示——但正在显示完全扩大。 我希望它的工作方式:如果我说是关于“About Us”的,那么只有最高层次选择。 (About Us、我们的领导团队、我们的工作人员和咨询委员会)

如果我点击“领导团队”的话,就会发现其中三个名字。 希望是有意义的。

这是我用多页称这一菜单:

                            <?php if( is_page(array(11,354,304,302,297,232,319,317,311,309)) ) :?>
                                <? wp_nav_menu( array( menu  =>  main-about  )); ?>
                            <?php endif;?>

希望得到任何帮助。

问题回答

我刚刚建成了一个网站,在那里,它被重新编辑成一个主要菜单和一个子午线。

我如何完成这项任务,是要把1个深度的主要菜单(只显示母子物品)。 页: 1

<?php wp_nav_menu( array(  container_class  =>  menu ,  theme_location  =>  primary ,  depth  =>  1 ,  menu  =>  3  ) ); ?>

然后,我必须做的是把儿童物品放在后面。 我不是要创造菜单,而是必须积极创造菜单。 因此,这并不是要为每个子手打字或换口,而是使用了以下的代码一。 而且,它可能不属于 lo。

注:这部法律取自互联网,经过修改,我不知道原作者。

<?PHP
// Get the parent s title (For display purpose)
$str_parenttitle = get_the_title($post->post_parent);

// This will display the child items of the parent
// And if it s a child item, display it s siblings
if($post->post_parent)
    $children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->post_parent."&echo=0&depth=1&exclude=73"); 
else
    $children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->ID."&echo=0&depth=1&exclude=73");
?>

然后显示菜单

<?PHP if ($children && is_page()): ?>
    <ul class="menu">
        <li <?php if ( is_page() && $post->post_parent ) {} else { ?>class="current_page_item"<?php } // Shows the parent item on the sub menu ?>>
            <a href="<?php echo get_permalink($post->post_parent) ?>"><?php echo $str_parenttitle;?></a>
        </li>
        <?php echo $children; ?>
    </ul>
<?PHP endif; ?>

我希望这至少是有助益的。





相关问题
Wrap stray text in <p> tags

Wordpress issue.. how do I wrap stray text in P tags? Example: Before- <div class = "content"> <img src = "hello.jpg"/> <h1>Introduction</h1> Hello! this is ...

Using jQuery Plugins with Wordpress

Having a bit of trouble using jQuery plugins (Superfish, jQuery UI, etc) using Wordpress. Everything works fine in my plain non-Wordpress site, but Wordpress seems to conflict with JQuery. There must ...

WordPress Data Storage Efficiency

I ve been asked to review a WordPress plugin of sorts and try to find ways of making it faster. The premise of this plugin is basically to store a bunch of users and shifts and appointments and ...

Why can t I properly style a blockquote in Wordpress?

On the design I just created for my website, I have a blockquote styled with two quote images using the span technique in css: blockquote { background-image: url(images/openquote.jpg); background-...

How does the WordPress <!--nextpage--> tag actually work?

What happens? I m guessing that somehow the post or page is parsed before displaying, and then just split into two methods? I can t seem to find any documentation on how the underlying <?php ...

Wordpress Plug-ins: How-to add custom URL Handles

I m trying to write a Wordpress Plug-in but can t seem to figure out how you would modify how a URL gets handled, so for example: any requests made for: <url>/?myplugin=<pageID> will ...

热门标签