duandong1869 2017-03-14 20:17
浏览 48

如何在我的Wordpress儿童主题定制器中为单选按钮选项输入正确的图像路径URL?

I've been working on this for a while and even though i've searched through a lot of stackoverflow questions/answers, i haven't been able to find what i'm looking for.

My question:

I'm working on developing my first genesis wordpress child theme, particularly now the customizer. I want the user to be able to have different options, one of which is choosing from a few background patterns that I've designed for a certain div class. There are three different patterns, and I've been able to so far make three radio buttons. Here is the code:

$wp_customize->add_setting('BG_Pattern', array( 'default' => '#f5ebdf',));
$wp_customize->add_control('BG_Pattern', array(
  'label'      => __('Background Pattern', 'FoxiePro'),
  'section'    => 'backgrounds',
  'settings'   => 'BG_Pattern',
  'type'       => 'radio',
  'choices'    => array(
   'tan.jpg'   => 'Tan',
   '#e6e6e6'   => 'gray',
   'teal'      => 'teal',

  ),
));

And the output is this, in the header.php file:

<?php
$BG_Pattern = get_theme_mod('BG_Pattern');
?>
<style>
  .enews-widget {background-image: url( '<?php echo $BG_Pattern; ?>' );}
</style>

Where it says "tan.jpg", is where I would like to put in a url to tan.jpg src, which is in my child theme folder. However, any link I put in doesn't make the pattern appear. Inputting something like:

'bloginfo('template_url'); ?>/images/tan.jpg' => 'Tan',

also hasn't worked for me. Anyone have any ideas? Thanks!

</div>
  • 写回答

1条回答 默认 最新

  • duanjia3187 2017-03-14 21:27
    关注

    Figured it out, because it's a child theme, needed to use the following:

    get_stylesheet_directory_uri() . '/images/backgrounds/tan.jpg'   => 'Tan',
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?