The issue is caused by the query_posts
function, this function alters the global $wp_query which the menu walker uses to check and add classes like current_page_menu
to menu items.
A solution would be to write a new custom query and loop through that than using query_posts
.
$title_slug = strtolower(str_replace( " ", "-" , the_title_attribute('echo=0') ) );
$id_obj = get_category_by_slug($title_slug);
$cat_id = $id_obj->term_id;
$args="cat=".$cat_id.'&post_status=publish,future&paged='.get_query_var('paged');
// The Query
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) : ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
//YOUR CONTENT
<?php endwhile; ?>
/* Restore original Post Data */
<?php wp_reset_postdata(); ?>
<?php endif; ?>
References: