繁体   English   中英

如何在Wordpress儿童主题自定义程序中为单选按钮选项输入正确的图像路径URL?

[英]How can I put in a proper image path URL for radio button options in my Wordpress Child Theme Customizer?

我已经为此工作了一段时间,尽管我已经搜索了很多stackoverflow问题/答案,但仍无法找到所需的内容。

我的问题:

我正在开发我的第一个创世纪wordpress儿童主题,尤其是现在的定制器。 我希望用户能够有不同的选项,其中之一是从我为某个div类设计的一些背景模式中进行选择。 共有三种不同的模式,到目前为止,我已经能够制作三个单选按钮。 这是代码:

 $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', ), )); 

输出结果是在header.php文件中:

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

我要在其子主题文件夹中的tan.jpg src网址中输入“ tan.jpg”。 但是,我插入的任何链接都不会显示该模式。 输入类似:

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

也没有为我工作。 有人有想法么? 谢谢!

弄清楚了,因为它是一个子主题,所以需要使用以下内容:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM