Created
November 30, 2017 14:00
-
-
Save jimmy89Li/8cabf6d360bfe008624c304af8116895 to your computer and use it in GitHub Desktop.
WP nav menu excluding pages with specific template
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
<nav class="navmenu"> | |
<?php | |
$args = array( 'post_type' => 'page', 'posts_per_page' => -1, 'fields' => 'ids', 'meta_query' => array( array( 'key' => '_wp_page_template', 'value' => 'page-gallery.php', 'compare' => '=', ) ), ); | |
$pages_to_exclude = new WP_Query( $args ); | |
wp_page_menu( array( 'before' => '<ul class="sf-menu">', 'sort_column' => 'menu_order, ID', 'menu_class' => 'primary-menu', 'exclude' => implode( ',', $pages_to_exclude->posts ), ) ); | |
?> | |
</nav> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment