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


  • 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

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.


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"

  • How does this answers the Question? – brasofilo Nov 6 '12 at 16:27

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

while (have_posts()) : the_post();
    get_template_part( 'content', get_post_format() );

wp_reset_query(); does all the magic :)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.