stephenharris / WordPress-Post-Type-Archive-Links

Adds a metabox on Appearance > Menus to create menu items pointing to post type archives
55 stars 25 forks source link

All post type archives #10

Closed JvanderHeide closed 11 years ago

JvanderHeide commented 11 years ago

Usefull in somecases to create hierarchy in wordpress navigation and the menu hightlighting that comes with it. I was working on a project where a custom navigation was needed, but without the plugin (and the changes I've made) it was impossible to get proper menu highlighting and easy to manage navigational items.

I've used this plugin with the changes to set my defaults posts as a child to my "Blog"-page so that propper menu hightlighting is used ('.current-menu-parent, .current-menu-ancestor'). The same goes for custom post type archives where the menu highlighting was lacking when just using a custom navigation link (as in a direct URL to the archives).

The changes were needed to get the above mentioned results. It might be an idea to make these changes optional for someone with Admin rights to turn them on or off.

P.S.: I've previously request a pull on your other account's fork, my bad.

stephenharris commented 11 years ago

Thanks @JvanderHeide :)

As I mentioned here I'll look into this (i.e. try to remember why I excluded built in post types).

R.e. fork on old account - no worries, I need to keep the old one for various 404-related reasons :).

JvanderHeide commented 11 years ago

Allright, keep me posted :) I'm curious what made you do so back then.

stephenharris commented 11 years ago

Sorry its taken so long to get back to you on this. Just tested out the PR, it seems that the in-built post types don't have archive pages (pages, posts, media). So you can add them to the menu - but there's no link...

mrk87x commented 11 years ago

Correct, having a static homepage I had the same issue with your plugin, I tried to modify php functions to include _builtin post types, but the wordpress function get_post_type_archive_link( $post_type ); won't give you any url for the link on menu. I solved the problem for posts archive link this way: create a page to be the dedicated archive, but just fill the name and leave it's default template as it is, then in Settings -> Reading set the "Front page displays" as static page as it follows: Front page: #theStaticPageYouChooseAsHomepage , Posts page: #theStaticPageYouChooseAsArchive To finish add to the Appearance -> Menus the page you created to link to the news archive. Any Template assigned the Posts Page will be ignored and the theme's index.php (or home.php if it exists) will control the display of the posts.

Hope it helps, I found this solution on my own and it was a bit hard.

stephenharris commented 11 years ago

@mrk87x Technically the built-in post 'post' and 'page' post types don't have archives, which why its not supported by the plug-in.

Are (other) there in-built post types with archives?

stephenharris commented 11 years ago

(If there are, feel free to reopen :))