Skip to content

Instantly share code, notes, and snippets.

@Jonnyauk
Created February 7, 2015 00:24
Show Gist options
  • Save Jonnyauk/94c2cc4fbdcffc378651 to your computer and use it in GitHub Desktop.
Save Jonnyauk/94c2cc4fbdcffc378651 to your computer and use it in GitHub Desktop.
Empty menu callback
<?php
/*
NOTE: Insert into template file as usual but use fallback_cb parameter - same name as function
wp_nav_menu( array(
'container_class' => 'primary-navigation clearfix',
'theme_location' => 'primary-nav',
'fallback_cb' => 'mywfx_empty_menu'
) );
*/
function mywfx_empty_menu() {
$page_data = wp_list_pages(array(
'post_type' => 'page',
'post_status' => 'publish',
'echo' => 0,
'number' => 3,
'title_li' => ''
));
echo '<ul class="menu">';
echo $page_data;
echo ( current_user_can( 'manage_options' ) ) ? '<li>' . '<a href="' . admin_url( 'nav-menus.php' ) . '">' . 'Edit this menu' . '</a>' . '</li>' : '';
echo '</ul>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment