Hello, I'm working on a portfolio site.
Created custom post type called "portfolio", and using a taxonomy called "disciplina" with some values... design, web, photography, etc.
I'm using Thematic framework and WP menu.
I have added some menu items for listing projects by taxonomy. With instructions posted here:
and here:
http://wordpress.org/support/topic/custom-post-type-parent
I'm trying to make different, with a class, the current menu item of the taxonomy of the portfolio item, with this code:
function current_type_nav_class($classes, $item) {
# get Query Vars
$post_type = get_query_var('post_type');
$taxonomy = get_query_var( 'disciplina' ) ;
//$taxonomy = get_the_term_list( $post->ID, 'disciplina', '', ', ', '' );
//$taxonomy = get_term_by( 'slug', '', get_query_var( 'disciplina' ) ); //echo $term->name;
echo $taxonomy;
# get and parse Title attribute of Menu item
$title = $item->attr_title; // menu item Title attribute, as post_type;taxonomy
$title_array = explode(";", $title);
$title_posttype = $title_array[0];
$title_taxonomy = $title_array[1];
//echo $title_taxonomy;
# add class if needed
if ($post_type == 'portfolio') {
if ($title != '' && ($title_posttype == $post_type || $title_taxonomy == $taxonomy)) {
echo 'ENTER!';
array_push($classes, 'current-menu-item');
};
}
return $classes;
}
add_filter('nav_menu_css_class', 'current_type_nav_class', 10, 2 );
I am not able to recover current taxonomy in the custom post type page. $taxonomy doesn't have a value.
I know once the code recovers the current taxonomy, it will work. Notice that I have also tested other solutions, none of them are returning anything.
Hope somebody can guide me. Thank you!