Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function new_nav_menu_items($items) {
- $items = "";
- $args = array(
- "post_type" => "page",
- "order" => "ASC",
- "orderby" => "menu_order"
- );
- $the_query = new WP_Query($args);
- if($the_query->have_posts()):
- while($the_query->have_posts()):
- $the_query->the_post();
- $items .= '<li><a href="#post-'. get_the_ID() .'">' . get_the_title() . '</a></li>';
- endwhile;
- else:
- echo "";
- endif;
- return $items;
- }
- add_filter("wp_nav_menu_items", "new_nav_menu_items");
- function new_nav_menu_items( $items, $args ) {
- if ( $args->menu == 'primary' ) {
- $items = "";
- $args = array(
- "post_type" => "page",
- "order" => "ASC",
- "orderby" => "menu_order"
- );
- $the_query = new WP_Query( $args );
- if ( $the_query->have_posts() ):
- while( $the_query->have_posts() ):
- $the_query->the_post();
- $items .= '<li><a href="#post-' . get_the_ID() . '">' .
- get_the_title() . '</a></li>';
- endwhile;
- else:
- echo "";
- endif;
- }
- return $items;
- }
- add_filter( "wp_nav_menu_items", "new_nav_menu_items" );
Add Comment
Please, Sign In to add comment