I am using the following to help display a list of posts created in a custom post type.
$args = array(
'post_type'=>'portfolio',
'title_li'=> __('Portfolio')
);
wp_list_pages( $args );
However a class is not being added to the list item of the current page (current_page_item
). Any ideas of how I could make this happen?
Check this ticket: http://core.trac.wordpress.org/ticket/17590
Quickfix by husobj:
The quickfix might be an easier alternative?
Cheers
Found this and it works perfectly!
Dynamic navigation for custom post type (pages)
You can use this code to make the parent post type active in the menu:
I found this code in this Gist and it worked for me – it marks the parent navigation as active when on a custom post type single post.
You need to add this to your functions.php:
Via http://kucrut.org/wp_list_pages-for-custom-post-types/
I’d like to add a workaround that worked in my situation.
I had Custom Post Type with Custom Taxonomy and wanted to list these posts as long as they were in a particular Custom Category – with current page class on the
li
.The code above
*
produced a list of all posts, but didn’t filter categories.*
[editor note] Answers may vary its order, not sure what code is being referred.My solution comes from that code, not sure if it’s best practice, but it works..
helps me adding currently active class to current menu item when I LOOP
wp_get_nav_menu_items
asforeach($primary_nav_menu_items as $n => $menu_item){#do something}
. It may help someone.