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>
You 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.