I tested this tutorial: http://qnimate.com/creating-a-one-page-wordpress-theme/
It works great.
The problem is that in the tutorial there is one menu while I have 2 menus.
Let me know how I can customize this function: http://qnimate.com/creating-a-one-page-wordpress-theme/#Linking_Menu_Items_to_Internal_Parts_of_Page
for the feature only applies to primary menu.
The code :
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");
I tried with if( $args->theme_location == 'primary' )
but I do not know how to use it ..
Thank you
🙂
You can try post_type = nav_menu_item.
And build your menu via the Theme > Menus.