Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am coming here for advice mainly, because I am stuck on what to do next. Within my latest project, I am using Wordpress at the backbone, as a fully fledged CMS system. I have styled every single page, and the theme is looking great! One problem however:

I am going to be posting not so news-y posts as guides, information and video compilations. I don't want to be adding hundreds of wordpress pages, I would much prefer have posts categorized and then display them in the navigation.

Yep, that is the problem. I am just wondering if it is possible to, without much code, and without hacking away at core files, be able to have the navigation like this:

  • Home
  • Guides
    • Posts in the Guides category displayed
  • Videos
    • Posts in the videos category displayed

I wouldn't want this for every single category however.

So how long would this take me, would it require much coding and is there already and existing plugin that does this?

Thanks!

share|improve this question
add comment

2 Answers 2

It shouldn;'t be so hard. All you have to do is to use wp_get_nav_menu_items filter.

This will add 10 posts to submenu of item which title is equal to ''.

function insert_my_posts_to_menu( $items, $menu, $args ) {
    $menu_order = count($items);

    $child_items = array();
    foreach ( $items as &$item ) {
        if ( $item->title != '<SOME MENU ITEM TITLE>' ) continue;

        foreach ( get_posts( array('post_type'=>'post', 'numberposts'=>10 ) as $post ) {
            $post->menu_item_parent = $item->ID;  // add post to submenu of current item
            $post->post_type = 'nav_menu_item';
            $post->object = 'custom';
            $post->type = 'custom';
            $post->menu_order = ++$menu_order;
            $post->title = $post->post_title;
            $post->url = get_permalink( $post->ID );
            $child_items[] = $post;
        }
    } 
    return array_merge( $items, $child_items );
}
add_filter( 'wp_get_nav_menu_items', 'insert_my_posts_to_menu', 10, 3 );

Then you should also take care of current classess, I guess.

share|improve this answer
    
Time to get messy with the code then I guess, haha. I am looking a displaying all articles within a category, or at least the most I can. They are organised in many sub-categories and there isn't too many in each. Thank you Ill give it a whirl! –  Jake Ball Jul 16 '13 at 8:05
add comment

I think this isn't able to do without (much) coding, check this URL. http://codeseekah.com/2012/03/05/list-all-posts-in-wordpress-navigation-menu/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.