我对WordPress主题开发还比较陌生,因此我必须使用选项树创建一个主题.我已经在wordpress主题中成功添加了带有选项树插件的一些选项.但是当我去添加Background选项时,我确实站了起来.我在完整的章节中设置了主题类型为'type'=>'background'的设置,在我看到仪表盘上的主题选项为"select color","background-repeat","background-attachment", 背景位置"和背景尺寸.现在我想查询所有方法,但是我不知道该怎么做.我确实想动态编写这段代码 body {background:url(来自选项树附件文件)选项树重复选项滚动选项树位置选项树背景大小选项树颜色}
I'm relatively new to WordPress theme development, and I had to create a theme with options tree. I have successfully add some options with options tree plugin in my wordpress theme.But i am really stand when i go to add Background option. I have complete section an settings on theme option with 'type' => 'background', after i see i have find some options on dashboards theme options like 'select color', 'background-repeat', ''background-attachment', 'background-position' and background size. Now i want to query all methods but i have did'nt know how can i do this. exactly i want to do dynamic this code body{background:url(from option tree attach file) option tree repeat option scroll options tree position options tree background size options tree color}
这是确切的CSS正文{background:url(img/body_bg.png)不重复滚动0 0#ddd}.任何人请帮助我.
this is exact css body{background:url(img/body_bg.png) no-repeat scroll 0 0 # ddd}. Any one Please help me.
推荐答案您可以尝试执行以下操作....
You can try something like this....
<?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';} ?>) ; }我个人将其用于我的高级主题. www.wpmania
I personally use this for my premium themes. www.wpmania
更多推荐
如何在WordPress主题中使用选项树添加所有背景选项?
发布评论