Created
February 7, 2015 00:24
-
-
Save Jonnyauk/94c2cc4fbdcffc378651 to your computer and use it in GitHub Desktop.
Empty menu callback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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