Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress latest posts menu item

I'm trying to get Wordpress to give me a menu item to go to "latest posts." They come up on the frontpage, but once I navigate away, I want a menu item to get back there. It seems so obvious, but several hours later, the best I could do was create a custom menu with a link to "uncategorised" as a workaround. There MUST be a better way! And this way, I get a box saying "Archive of posts filed under the Uncategorized category. " Not wanted!

like image 956
Robin ANDREWS Avatar asked Nov 03 '22 06:11

Robin ANDREWS


2 Answers

Create a custom page in your template directory (http://codex.wordpress.org/Pages#Page_Templates) with a custom query (check at http://codex.wordpress.org/Class_Reference/WP_Query, http://codex.wordpress.org/Function_Reference/query_posts or http://codex.wordpress.org/Template_Tags/get_posts).

Create a page in your admin and select the template you created.

Add a link to this page in your menu and you're done.

like image 120
Louis XIV Avatar answered Nov 10 '22 19:11

Louis XIV


Maybe this will help: http://www.viper007bond.com/2011/09/20/code-snippet-add-a-link-to-latest-post-to-wordpress-nav-menu/

It's a filter that will 'search and replace' placeholder anchors such as '#latestpost1' with the actual url of the latest post, and thus dynamically modify the menu before it's rendered.

I'm not sure how this is for SEO, but it's a clever solution.

like image 35
mikkelbreum Avatar answered Nov 10 '22 21:11

mikkelbreum