0

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.

1
  • Is it possible to do a foreach of the main tree?
    – Rob
    Aug 30, 2011 at 12:07

2 Answers 2

0

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

0
    <?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();
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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