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>

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.

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

2 Answers 2


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


$pages = get_children(array('orderby' => 'menu_order', 'order' => 'asc'));
foreach($pages as $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>

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.