How to insert link to the default post archive into a menu

I can add categories, I can even add a custom post type archive, but I can’t add the original posts archive.

It’s not among the page list.

Read More

I worked around this by creating a page, creating a page-pagename.php file, displaying the posts there and linking to that page, but when that page is shown, the menu item doesn’t have the ‘current-menu-item’ class.

Related posts

Leave a Reply

2 comments

  1. If you don’t have static front page

    Since you can add a custom post type archive, then just specify post_type=post.

    If you have static front page

    Go to Settings -> Reading and specify posts page you’ve created as Posts page from dropdown. Now all necessary classes will be added to Nav Menu — current-menu-item, current-menu-parent, current_page_item, current_page_parent among others.

    Be sure to create custom template for this page. Otherwise it will utilize page.php template file. You can alter a copy of category.php.

  2. Instead of finding out how to put a custom archive link in the menu (which would still be nice to know), I found the problem with my custom page template solution.

    To display the posts in the News page template I obviously had to alter the original query, which carried the News page record. Since the footer, which was outputting the menu, only came after the loop, it couldn’t find out which page it was on – hence it couldn’t correctly assign the current-menu-item class.

    All it took was a wp_reset_query(); command after the custom loop and we’re good.