WordPress:条件为Post模板不PAGE

时间:2016-09-19 11:52:50

标签: php wordpress conditional custom-post-type

复制#include <stdio.h> int main(void) { float n, content; char operator; int active = 1; n = content = 0; printf("Begin Calculations:\n"); while (active && scanf("%f %c", &n, &operator) == 2) { switch (operator) { case 's': case 'S': content = n; printf("= %f\n", content); break; case '+': content = content + n; printf("= %f\n", content); break; case '-': content = content - n; printf("= %f\n", content); break; case '*': content = content * n; printf("= %f\n", content); break; case '/': content = content / n; printf("= %f\n", content); break; case 'e': case 'E': printf("End of calculations\n"); active = 0; break; default: printf("Invalid input\n"); break; } } return 0; } 后,我制作了一个名为single-download.php的自定义帖子模板。但是,有些自定义我不想在single.php上显示,但我无法获得特定的条件来实现相同的目标。

我尝试了single-download.phpif(is_page_template( 'single-download.php' )),但两人都没有工作。

我们有什么方法可以实现POST模板调节吗?感谢

1 个答案:

答案 0 :(得分:0)

好的,我终于明白了。我们需要使用

if( !is_singular( 'download' )

OR

if ( is_singular( 'download' ) ) {
// conditional content/code
}

就这么简单:)