如何在WordPress主题中使用选项树添加所有背景选项?

编程入门 行业动态 更新时间:2024-10-20 03:32:55
本文介绍了如何在WordPress主题中使用选项树添加所有背景选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我对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主题中使用选项树添加所有背景选项?

本文发布于:2023-11-23 19:54:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622692.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:选项   背景   主题   如何在   WordPress

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!