WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
  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


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

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
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

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

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 :)

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

Your Answer


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.