0

嗨,我想知道是否有人可以帮助我在索引提要上检查帖子类型的正确语法,目前我正在尝试这个 -

<div class="<?php if(is_home() )
{<?php if ( 'movies' == get_post_type() ) { echo 'textbox';}?> ;}?>">
</div>
4

2 回答 2

0

不需要多个 PHP 打开标签。

<div class="<?php if (is_home() && (get_post_type() == 'movies')) { echo 'textbox';} ?>">    </div>

在这种情况下我可能会做的就是把它弄清楚一点:

<?php
$class = (is_home() && get_post_type()==='movies') ? 'textbox' : '';
echo '<div class="', $class, '"></div>';
于 2013-08-06T03:35:36.043 回答
0
if ( is_front_page() && is_home() ) {
   // Default homepage

   } elseif ( is_front_page()){
     //Static homepage

   } elseif ( is_home()){

     //Blog page

   } else {

     //everything else

   }
}
于 2016-09-26T23:10:17.623 回答