I want to create a custom menu in the style below, can this be done? The code in brackets needs to grab the actual page content for each page.

<div class="menu-button-(page-name)">
<a href="(page-link)">(page-name)</a>
</div>

How can I use that one small bit of code to create my menu? That code should generate buttons for 5 pages that are in the main tree in the admin.

link|improve this question

Is it possible to do a foreach of the main tree? – Rob Aug 30 '11 at 12:07
feedback

2 Answers

Rob, take a look at using register_nav_menu function in WordPress it allows you to build custom menus with ease.

http://codex.wordpress.org/Template_Tags/register_nav_menu

link|improve this answer
feedback
up vote 0 down vote accepted
    <?php 
$pages = get_children(array('orderby' => 'menu_order', 'order' => 'asc'));
foreach($pages as $post) {
setup_postdata($post);
$fields = get_fields();
?>

    <div class="menu-button-<?php echo $post->post_title; ?>">
        <a href="<?php echo get_page_link( $post->ID ); ?>"><?php echo $post->post_title; ?></a>
    </div>
<?php
}
wp_reset_query();
?>
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.