Today while working on a site I came across a problem that seemed weird to me. The wp_nav_menu was working fine on all the pages except for my category page. When I took a detailed look, I found that it was caused by conflict of custom post type. So how did I fix it?
Well here is a quick fix. Copy and paste the following code right above the place where you have called the wp_nav_menu function.
<?php
if(is_category()){
$wp_query = NULL;
$wp_query = new WP_Query(array(‘post_type’ => ‘post’,’page’));
}
?>
You may add other post types as per your need.
That’s it for the time being. Let me know if it helped or if it does not too, you could always leave a comment.
Rodney says
Life Saver mate! Thanks ;)
Nik says
Thanks Buddy :)
You Make my day
Van says
Neat and clean tips ! That just solved my problem
Remus says
Thanks, saved me a lot of time!
jan zikmund says
Thanks a lot!
Just to make it “correctly”, you should call after displaying the menu.. otherwise you change the loop for the display that comes next.
Cheers!
jan zikmund says
my tag was removed.. I meant you should call wp_reset_query();