Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //add custom post type to tags and categories
- function add_custom_types_to_tax( $query ) {
- // Return right away if in admin or not working on the main frontend query
- if ( is_admin() || ! $query->is_main_query() ) {
- return;
- }
- // Check if we're on a category or tag archive. If so, add our post type
- if( ( $query->is_category() || $query->is_tag() ) ) {
- // Get all your post types
- $post_types = array('post' , 'custom-post-type-goes-here');
- $query->set( 'post_type', $post_types );
- }
- }
- add_action( 'pre_get_posts', 'add_custom_types_to_tax' );
Advertisement
Add Comment
Please, Sign In to add comment