如何在wordpress主题中添加选项树的所有背景选项?

Foy*_*ran 1 wordpress tree options

我对WordPress主题开发比较陌生,我不得不用选项树创建一个主题.我已经成功地在我的wordpress主题中添加了一些选项树插件的选项.但是当我去添加背景选项时,我真的很有立场.我有完整的部分主题选项设置'type'=''background',之后我看到我在仪表板主题选项上找到一些选项,如'选择颜色','背景重复',''背景附件', '背景位置'和背景大小.现在我想查询所有方法,但我不知道我该怎么做.我想做动态这个代码体{background:url(来自选项树附件)选项树重复选项滚动选项树位置选项树背景大小选项树颜色}

这是精确的css body {background:url(img/body_bg.png)no-repeat scroll 0 0 #ddd}.任何人请帮助我.

小智 5

你可以试试这样的......

<?php $bg_body = ot_get_option( 'bg_body', array() ); ?> 
body
{ 
background-color: <?php if($bg_body['background-color']){echo $bg_body['background-color'] ; }else{ echo '#ffffff';} ?>;
background-repeat:<?php if($bg_body['background-repeat']){echo $bg_body['background-repeat'] ; }else{ echo 'repeat-x';} ?>;
background-attachment:<?php if($bg_body['background-attachment']){echo $bg_body['background-attachment'] ; }else{ echo 'fixed';} ?>;
background-position:<?php if($bg_body['background-position']){echo $bg_body['background-position'] ; }else{ echo 'top';} ?>;
background-image:url(<?php if($bg_body['background-image']){echo $bg_body['background-image'] ; }else{ echo get_template_directory_uri().'/images/bg.png';} ?>) ;
}
Run Code Online (Sandbox Code Playgroud)

我个人使用这个作为我的高级主题.www.wpmania.net