WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#36192 closed defect (bug) (duplicate)

Custom post types don't show on built in taxonomies

Reported by: pcfreak30 Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.4.2
Component: Query Keywords:
Focuses: Cc:

Description

If you add a CPT, then add support for the built in category or tags, the categories page(s) for those taxonomies will not show the CPT items, only post/page.

The following action has to be used to fix it:

add_action('pre_get_posts', function (&$wp_query) {
    if (is_category()) {
        $wp_query->query_vars['post_type'] = 'any';
    }
});

Change History (1)

#1 @swissspidy
5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #19471.

See also #16233

Note: See TracTickets for help on using tickets.