This code : http://icodesnip.com/snippet/php/wordpress-show-custom-types-in-categories

.. achieves its purpose which is to make category page work with a custom post type, but in my case it also destroys my custom menu, that is, my custom menu is empty. I want my custom menu AND my category page to work.

link|improve this question

70% accept rate
feedback

1 Answer

Custom nav menus are also a query, which you end up altering with that code. Your best bet is to check to make sure it's the main query, e.g. by globaling $wp_the_query and doing a strict comparison with $query or doing $query->is_category() instead (I believe that works - somebody will smack me down if it doesn't). In 3.3, there will be the very convenient is_main_query().

link|improve this answer
Thanks helen it works !! There's a minor issue remaining though: in my category page, the number of pages seems to be calculated based on the value of 'Blog pages show at most' in my reading settings, NOT on the posts_per_page parameter in my category page's loop. So I'm forced to use the reading settings in my category page, I can't set my own posts per page number because the number of pages won't match ... Any idea how can I fix that ? – Mike Dec 4 '11 at 8:55
If you're using the pre_get_posts hook it really should calculate the number of pages based on that. – helenhousandi Dec 4 '11 at 18:49
feedback

Your Answer

 
or
required, but never shown

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