最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Conditional for single-{post-type}.php

matteradmin7PV0评论

Please help with this code for custom post type "video":

If is single-video.php page {

     list custom-taxonomy of video. Example actors

} Else { do nothing }

I´m tried with is_single, is_singular, is_page_template but imposible.

Please help with this code for custom post type "video":

If is single-video.php page {

     list custom-taxonomy of video. Example actors

} Else { do nothing }

I´m tried with is_single, is_singular, is_page_template but imposible.

Share Improve this question edited Jan 31, 2012 at 20:54 Chip Bennett 55.1k8 gold badges91 silver badges170 bronze badges asked Oct 5, 2011 at 15:40 FontepinkFontepink 1611 gold badge1 silver badge6 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 31

According to the WordPress conditional docs it should be:

if ( is_singular( 'video' ) ) {
     // do conditional stuff

} else {
     //do other stuff
}

Also if you want a blank page or no content to show when the CPT is not video you don't really need the else so you could omit it. You could ALSO do something like:

if ( ! is_singular( 'video' ) ) {
     // do nothing

} else {
     //do conditional stuff
}

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far