无法定位特定类别以替换wordpress中的背景图像

时间:2011-07-06 21:06:21

标签: php wordpress wordpress-theming if-statement

我正在尝试根据用户所在的页面或类别更改背景图片。我似乎无法让代码适用于类别。

网址:http://asvpart.com/new/category/portfolio/

代码:
`

    <?php $cat_obj = $wp_query->get_queried_object(); $cat_id = $cat_obj->cat_ID; ?> 

    <?php if (is_page('5') ):
          // page home ?>
        <style type="text/css">
        body {background-color:#000;background-image:url(http://asvpart.com/new/wp-content/uploads/2011/07/bkgrnd_gallery.jpg);background-repeat:no-repeat; background-size: 100%;}
        </style>

        <?php elseif (in_category('portfolio') ):
        // category 5 ?>
        <style type="text/css">
        body {background-color:#000;background-image:url(http://asvpart.com/new/wp-content/uploads/2011/07/bkgrnd_gallery.jpg);background-repeat:no-repeat; background-size: 100%;}
        </style>

` 我不确定为什么“投资组合”不会针对“投资组合”帖子

0 个答案:

没有答案