WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#13507 closed defect (bug) (invalid)

Conditional tag for post type and taxonomy

Reported by: ojp3d Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: General Keywords: reporter-feedback
Focuses: Cc:

Description

I'm using MAMP on a Mac, and trying to filter posts using conditional tags, but other posts are passing...

( is_post_type( 'sermons' ) && is_taxonomy( 'preacher' )
is_taxonomy( 'series' ) )

It still doesn't work when I try just:

( is_taxonomy( 'preacher' )
is_taxonomy( 'series' ) )

I'm running the latest beta. And it is not a problem of wp_reset_query()... I tested without any query before.

Change History (4)

comment:1 ojp3d4 years ago

The codes are:

( is_post_type( 'sermons' ) && is_taxonomy( 'preacher' ) || is_taxonomy( 'series' ) )
is_taxonomy( 'preacher' ) || is_taxonomy( 'series' )

comment:2 westi4 years ago

  • Cc westi added
  • Keywords reporter-feedback added
  • Priority changed from high to normal

What intersection are you trying to achieve?

Could you attach some example code with the calls for registering the post_types and taxonomies so we can reproduce.

Cheers

comment:3 nacin4 years ago

Neither of these are conditional tags. is_taxonomy and is_post_type tell you if it is registered.

For conditional tags, you'll want is_tax, and probably is_singular (we haven't acted on #12588 yet).

comment:4 dd324 years ago

  • Milestone 3.0 deleted
  • Resolution set to invalid
  • Status changed from new to closed

Neither of these are conditional tags. is_taxonomy and is_post_type tell you if it is registered.

Correct, Which is why this isn't working as expected.

use is_tax() + and the result from #12588

Note: See TracTickets for help on using tickets.