最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Conditional for single-{post-type}.php

programmeradmin3浏览0评论

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
}
发布评论

评论列表(0)

  1. 暂无评论