开发者

Trouble targeting a specific category to replace background images in wordpress

I'm attempting to change the background image based on what page or category the user is on. I can't seem to get the code to work for the categories though.

The url: http://asvpart.com/new/category/portfolio/

the code:

`

    <?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.jp开发者_如何学编程g);background-repeat:no-repeat; background-size: 100%;}
        </style>

` I'm not sure why the 'portfolio' will not target the 'portfolio' post

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜