Wordpress - is_page_template

时间:2015-03-16 18:13:04

标签: php wordpress responsiveness

我一直在使用以下代码在wordpress网站的某些页面上设置列宽:

if ( is_page_template( 'fullwidthhome.php' ) ) {
    global $content_width;
    $content_width = 1080; /* pixels */
  }
  elseif ( is_page_template( 'wideContent.php' ) ) {
    global $content_width;
    $content_width = 1080; /* pixels */
  }

这在包含自定义模板的网页上效果很好,但我不太确定如何让它适用于自定义帖子类型。

当我将模板设置为自定义帖子类型时,它似乎无法正常工作:

  elseif ( is_page_template( 'single-widecontent.php' ) ) {
    global $content_width;
    $content_width = 1080; /* pixels */
  }

有什么想法吗?

TIA!

斯蒂芬

3 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

很容易。它应该如下。

else if ( 'widecontent' == get_post_type() ) {

global $content_width;
$content_width = 1080; /* pixels */

}

答案 2 :(得分:0)

我实际上最后去了is_singular ('wideContent'):)

谢谢你们!

相关问题