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()
.
Related Posts:
- How do I get the permalink of a custom post type?
- Row actions for custom post types?
- How to set parent-child relationship between differents custom post types
- Add Custom Fields to Custom Post Type RSS
- Do I need a nonce field for every meta box I add to my custom post type admin?
- Restrict custom post type to only site administrator role
- Add content in custom post type page after the title and before columns
- get attachments for all posts of particular post type
- Check if a custom taxonomy archive page is being displayed
- How to limit the number of terms (terms acts like categories)
- Removing custom post type from link search results
- How to add a post from a custom post type as the static page?
- How can I get next/ previous post links to order by a filter (by the last word of the title)?
- How do I Make a custom post type get a custom post template in a plugin
- Check if current user has post in post type and is author role
- Priority for Categories, Tags, Taxonomies, Posts, Pages and Custom Posts with same url
- Using Custom Meta Capabilities on Custom Post Type
- Separating Search Results By Post Type
- Including a custom post type in the Archives widget
- Set default option in dropdown of WP_Query?
- How can I add single catogory for custom post type?
- How can I programmatically save data into custom fields that contain serialized data?
- Custom Post Types: Custom columns with Title submenu?
- Automatically Insert Custom Field on Custom Post Type Publish
- register multiple post types on one menu entry
- Create XML files on post edit screen
- Changing sort order with pre_get_posts using is_post_type_archive doesn’t change category pages
- Creating a custom post type using a object oriented approach?
- CPT Search Form with Taxonomy filter & Or
- Custom WP_Query not returning results when querying custom post type
- how to add extra GET parameters to post to url with add_rewrite_rule?
- Weird problem happening with custom taxonmy when creating/updating posts
- How to use the Display Name as the post title in a custom post type?
- Removing parent slug in hierachial custom post type
- CPT + CMB2: data not displaying for only first post in loop
- Remove edit or add facility for custom post type
- Why doesn’t a custom post type permalink ever hit index.php
- Random image from tag/custom type on sidebar
- Set a maxlength for the title input in a custom post type
- How to get categories linked in posts for a specific post type
- WP Rest API – How to get an empty response if query has no posts
- Accept additional argument on custom post type permalink
- Get general taxonomy name for a Custom Post Type
- Include custom post type content in search
- Get the category from custom post type
- Is it possible to store Custom Post Type data in separate set of tables and still have wp_post class functionality?
- Allow user to only access custom post type
- Filtering posts list table
- List Taxonomy Terms based on another Taxonomy
- Order post by date with ACF
- If Post Meta Equals Current Title Conditional Advanced Custom Fields
- Loop increase number
- delete_post_meta() for whole CPT / multiple posts?
- Move Genesis Single Page/Single Post Title
- Custom filter for main search: how to exclude specific post_type from search results
- Is This Code Efficient – Or is there a better way?
- Creating separate feeds for custom post types
- page template as a custom post type archive page
- How to use single.php for creating, reading and editing Custom Posts with ACF
- how to send email to administrator when someone edit post
- One Site. One Theme. Multiple Stylesheets without plugins?
- How to determine next custom post in hierarchy
- New post from database
- Easy reading or transfer of data from posts?
- Using WP meta query to show custom post types by a start and finish date
- Give a unique ID while saving
- Change permalinks for custom post type based on taxonomy term
- Updating post content and custom fields in edit post screen
- Add a class to post_class if more than one post shares same meta_value_num
- Getting the list of the latests posts and custom type posts in the homepage
- How to show Custom Post Types under Taxonomy in a new WordPress page template?
- How we can create menu from Appearance > Menu and use as a add-submenu-page for admin menu?
- Custom Post Type Category Displaying ALL Sub Categories as well
- Feature image Gallery made from Custom Post type + Categories
- Custom post type in slider front page Breaking layout
- register_rest_field update_callback don’t work for $_FILES
- Change the term based on the value of a $variable using wp_update_post in submitting a form
- Getting data from dynamically allocated metaboxes within a custom post
- Meta query broken since 4.7.4 Update
- Custom post type , page template not grabbing the page template
- Can I organise my custom post types by page?
- Display posts of a hierarchical custom post type excluding parent posts
- Best Plugins for Complex Index of Resources [closed]
- How Can a CPT in WordPress have a page 2 without an error?
- Get the custom post type slug but remove the rewrite prefix?
- Remove sequential number from permalinks
- custom post type archive slug vs. custom page template
- Site loads very slow for archive custom post type page
- WordPress loop for multiple custom post types
- how to add pagination and post query in taxonomy-taxonomy-term.php? [duplicate]
- Pagination not working with custom loop
- How to bring custom meta boxes to custom post types?
- Switched server & domain name, now custom post types won’t save
- Display one post based on ID from $_GET
- Don’t display post if post has empty body
- Posts picking up old Permalinks, how to reset?
- Custom Post Type to Plugin
- How to query posts by category with the_title();
- Same slug for Custom Taxonomy archive and CPT archive – Rewrite rule not working
- WordPress post objects in one parent post object