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.
  1. I have setup a custom post type called 'expertizeom'
    1. I have setup a page called "expertize" and added to my custom menu (site main nav).
    2. The page is rendered with an archive called archive-expertizeom.php

The problem is that when i browse to that page everything is working fine but wordpress isn't adding the current-menu-item class.

can you help? Thanks

Francesco

share|improve this question
    
I ran into this problem a while back and found this tutorial useful - wp.tutsplus.com/tutorials/theme-development/… It walks through creating a plugin to add a meta box for adding custom post type archives to the menu and solves the current-menu-item issue. (the link to the complete plugin is down the bottom if you're after a quick fix) –  user31525 Apr 15 '13 at 10:35
add comment

3 Answers

I've had the same problem and this worked for me:

query_posts('cat=3');
while (have_posts()) : the_post();
    get_template_part( 'content', get_post_format() );
endwhile;
wp_reset_query();

wp_reset_query(); does all the magic :)

share|improve this answer
2  
How do you know the asker used query_posts()? Most devs don't do that anymore. :) –  toscho Apr 6 '13 at 13:14
add comment

In my case, i'm using magic-fields-2 plugin to create custom post types - i had just to activate the option "Hierarchical - Whether the post type is hierarchical. Allows Parent to be specified"

share|improve this answer
    
How does this answers the Question? –  brasofilo Nov 6 '12 at 16:27
add comment

If you using wp nav menu you can use this to add the current-menu-item class put this in your theme functions.php file and remember to change "mypageslug" to your wanted current page:

function additional_active_item_classes($classes = array(), $menu_item = false){
    global $wp_query;

    if ( $menu_item->post_name == 'mypageslug' && is_page_template('archive-expertizeom.php') ) {
        $classes[] = 'current-menu-item';
    }

    return $classes;
}
add_filter( 'nav_menu_css_class', 'additional_active_item_classes', 10, 2 );

This Code adds the class "current-page-item" if you are on a page with the template archive-expertizeom.php and the menu have a post_name that matches the post_name "mypageslug ie the slug of the wanted page.

share|improve this answer
1  
Thankyou very much for the response but it is not working I've found another solution in the menawhile rarescosma.com/2010/11/… –  Francesco Jun 12 '12 at 12:26
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.