admin管理员组文章数量:1130349
I am currently building a wordpress theme. For the menu, I just want to display all the pages that are created in the order that they are created in (i.e. I don't want users to have to go into the 'menu' section of the site and create their own).
I tried using wp_page_menu and this worked HOWEVER I need to add a walker class to expand the functionality, which you can't do with this function. So I need a way to display all my pages with using wp_nav_menu as my code - is there a way to do this?
Here is my code currently:
<nav id="nav">
<?php wp_nav_menu( array( 'walker' => new Clapton_Nav_Walker ) ); ?>
</nav>
I am currently building a wordpress theme. For the menu, I just want to display all the pages that are created in the order that they are created in (i.e. I don't want users to have to go into the 'menu' section of the site and create their own).
I tried using wp_page_menu and this worked HOWEVER I need to add a walker class to expand the functionality, which you can't do with this function. So I need a way to display all my pages with using wp_nav_menu as my code - is there a way to do this?
Here is my code currently:
<nav id="nav">
<?php wp_nav_menu( array( 'walker' => new Clapton_Nav_Walker ) ); ?>
</nav>
Share
Improve this question
asked May 20, 2014 at 8:38
Sam SkirrowSam Skirrow
1072 silver badges11 bronze badges
1 Answer
Reset to default 3You could move away from wp_nav_menu() completely and instead use wp_list_pages().
See the codex for more information, but I believe this may be what you are looking for.
http://codex.wordpress/Function_Reference/wp_list_pages
I do understand that this function outputs the pages. The point I was trying to make though is that you can use this in conjunction with CSS to get it looking like a menu. I made an example page that includes this code:
<?php
/*
* Template Name: Testing
*/
?>
<link rel="stylesheet" type="text/css" href="http://nickyoungweb/zip/wp-content/themes/THS2012/style.css" />
<nav id="nav">
<?php
wp_list_pages( array(
'title_li' => ''
));
?>
<br style="clear: both; ">
</nav>
I have it linked to a stylesheet that contains this code:
/**** WP LIST PAGES NAV *****/
nav { }
nav li { list-style-type: none; float: left; }
nav li a { width: 50px; height: 30px; background: #000; color: #fff; padding: 10px; margin: 2px; }
nav li a:hover { background: #f00; color: #000; }
nav ul li { display: none; }
It is a very basic example of how you could make it work with this function.
Hopefully this helps clear up any confusion I might have caused you and also gives you an idea of how it CAN be done with this function.
I am currently building a wordpress theme. For the menu, I just want to display all the pages that are created in the order that they are created in (i.e. I don't want users to have to go into the 'menu' section of the site and create their own).
I tried using wp_page_menu and this worked HOWEVER I need to add a walker class to expand the functionality, which you can't do with this function. So I need a way to display all my pages with using wp_nav_menu as my code - is there a way to do this?
Here is my code currently:
<nav id="nav">
<?php wp_nav_menu( array( 'walker' => new Clapton_Nav_Walker ) ); ?>
</nav>
I am currently building a wordpress theme. For the menu, I just want to display all the pages that are created in the order that they are created in (i.e. I don't want users to have to go into the 'menu' section of the site and create their own).
I tried using wp_page_menu and this worked HOWEVER I need to add a walker class to expand the functionality, which you can't do with this function. So I need a way to display all my pages with using wp_nav_menu as my code - is there a way to do this?
Here is my code currently:
<nav id="nav">
<?php wp_nav_menu( array( 'walker' => new Clapton_Nav_Walker ) ); ?>
</nav>
Share
Improve this question
asked May 20, 2014 at 8:38
Sam SkirrowSam Skirrow
1072 silver badges11 bronze badges
1 Answer
Reset to default 3You could move away from wp_nav_menu() completely and instead use wp_list_pages().
See the codex for more information, but I believe this may be what you are looking for.
http://codex.wordpress/Function_Reference/wp_list_pages
I do understand that this function outputs the pages. The point I was trying to make though is that you can use this in conjunction with CSS to get it looking like a menu. I made an example page that includes this code:
<?php
/*
* Template Name: Testing
*/
?>
<link rel="stylesheet" type="text/css" href="http://nickyoungweb/zip/wp-content/themes/THS2012/style.css" />
<nav id="nav">
<?php
wp_list_pages( array(
'title_li' => ''
));
?>
<br style="clear: both; ">
</nav>
I have it linked to a stylesheet that contains this code:
/**** WP LIST PAGES NAV *****/
nav { }
nav li { list-style-type: none; float: left; }
nav li a { width: 50px; height: 30px; background: #000; color: #fff; padding: 10px; margin: 2px; }
nav li a:hover { background: #f00; color: #000; }
nav ul li { display: none; }
It is a very basic example of how you could make it work with this function.
Hopefully this helps clear up any confusion I might have caused you and also gives you an idea of how it CAN be done with this function.
本文标签: menusUse wpnavmenu to display ALL pages
版权声明:本文标题:menus - Use wp_nav_menu to display ALL pages 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749114801a2318005.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论