Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
    
Is it possible to do a foreach of the main tree? –  Rob Aug 30 '11 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.

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

share|improve this answer
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();
?>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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