doulan9188 2018-12-19 19:41
浏览 51

如何使用get_theme_mod在“选项”中访问此数组?

I'm trying to add a Custom Palette Control for a section inside my Customizer options using this library: http://www.hardeepasrani.com/2017/10/color-palette-control-for-wordpress-customizer/. Everything's set up inside functions.php, however I'm unable to access the colors inside the "green" array when adding it to my CSS.

Tried accessing them with <?php echo get_theme_mod('o2_color_palette'); ?> but it only returns the name of the array. Using get_theme_mod('o2_color_palette[1]') returns nothing, same as o2_color_palette[colors][1].

$wp_customize->add_setting( 'o2_color_palette', array(
    'default' => 'green',
    'capability' => 'edit_theme_options'
));
$wp_customize->add_control(new O2_Customizer_Color_Palette_Control($wp_customize, 'o2_color_palette', array(
    'label' => __('Color Scheme', 'WordpressTutorial'),
    'description' => __('Choose a color scheme for your website.', 'WordpressTutorial'),
    'section' => 'lwp_standard_colors',
    'choices' => array (
        'green' => array(
            'label' => 'Green',
            'colors' => array( '#bbdb9b', '#abc4a1', '#9db4ab', '#8d9d90', '#878e76' )
        ),
        'purple' => array(
            'label' => 'Purple',
            'colors' => array( '#29274c', '#7e52a0', '#d295bf', '#e6bccd' )
        ),
        'slate' => array(
            'label' => 'Slate',
            'colors' => array( '#b9bbbb', '#a2a3bb', '#5e5f87', '#b3b7ee', '#fbf9ff' )
        )
    ),
    'priority' => 5,
    'settings' => 'o2_color_palette'
)));

I need get_theme_mod to return the selected color palette's array of colors so I can apply them.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
    • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
    • ¥15 opencv图像处理,需要四个处理结果图
    • ¥15 无线移动边缘计算系统中的系统模型
    • ¥15 深度学习中的画图问题
    • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
    • ¥15 Python报错怎么解决
    • ¥15 simulink如何调用DLL文件
    • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
    • ¥30 线性代数的问题,我真的忘了线代的知识了