Ok, an answer to all. First, thank you for you help.
Anyway, none of your solutions really address my issue. I don\'t like custom links on nav menus, at all. And that\'s because they\'re not dynamic, you cannot build them dynamically. So when you move the site and change url (for example, from staging to production) you\'ll have to remember to manually change the links. Also, the client, who often is not a programmer, nor too used to computer/web/urls things, won\'t be able to properly manage it by himself.
EDIT: I\'ve found a solution to the above issue, so now Marek\'s answer can be considered reliable, at least to me: we can filter the nav_menu-generated urls so that they\'ll always use real site url:
function normalize_url($atts){
if( !parse_url($atts[\'href\'], PHP_URL_SCHEME) && $atts[\'href\'] != \'#\'){
$atts[\'href\'] = site_url() . $atts[\'href\'];
}
return $atts;
}
add_filter(\'nav_menu_link_attributes\', \'normalize_url\');
//Marek\'s way will cause wp_nav_menu not to correctly
//output parent/child classes, so here\'s an example of
//how to solve this issue too:
function fix_nav_classes($classes, $item){
//say I\'ve got some custom links: the \'Projects\' parent and a child that
//points to \'/selected_project/\' and I want always these classes for both
//parents and child items
if(is_post_type_archive(\'project\') || get_post_type() == \'project\'){
if($item->post_title == \'Projects\') $classes[] = \'current-menu-parent\';
if($item->url == \'/selected_project/\') $classes[] = \'current-menu-item\';
}
return $classes;
}
add_filter( \'nav_menu_css_class\', \'fix_nav_classes\', 10, 2 );
OLD ANSWER > good as alternative:
The problem here, is that wordpress consider the \'page\' nature first: if you assign a custom post type template (according to rules) to a page, that will not work. I think it\'s probably a permalink thing -> page has different permalink than the archive. I think I could fix just modifying the page\'s permalink OR the rewrite rule on register_post_type so that the 2 are the same, but this is not a good practice too.
So for now, just dumb page and a \'classic\' custom query. For those who need, just this:
global $wp_query;
$query_array = array(
\'posts_per_page\' => 15,
\'post_type\' => \'staff_member\',
\'post_status\' => \'publish\',
\'orderby\' => \'menu_order\',
\'order\' => \'ASC\'
);
$member = $wp_query->query($query_array);
I generally use this kind of code.. If one really needs all the wp sugar, he can also substitute the main query:
global $wp_query;
$original = $wp_query; // save for restore
$wp_query = new WP_Query();
$wp_query->query(array(
\'posts_per_page\' => 15,
\'post_type\' => \'staff_member\',
\'post_status\' => \'publish\',
\'orderby\' => \'menu_order\',
\'order\' => \'ASC\'
);
// here goes processing code and sugars
// if(have_posts()): while(have_posts()): the_post(); etc etc.. the_content() etc..
// restore the original
$wp_query = $original;
Have a nice day!