Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

color picker question in repeater #924

Closed
robbisy opened this issue Apr 22, 2016 · 2 comments
Closed

color picker question in repeater #924

robbisy opened this issue Apr 22, 2016 · 2 comments

Comments

@robbisy
Copy link

robbisy commented Apr 22, 2016

I'm trying to use repeater's color picker result with wp_add_inline_style
but since the principle of repeater is to add multiple repeatable blocks of fields i don't see how style differently this repeatable blocks of fields. For example in my repeater i have a title field and a color picker

<?php
function my_styles_method() {
    wp_enqueue_style(
        'custom-style',
        get_template_directory_uri() . '/css/custom_script.css'
    );
        $repeater_value = get_theme_mod( 'my_repeater', array() );
        $color = $repeater_value[0]['background_color'];
        $custom_css = " 
            .titlecolor{
                        background-color: {$color};
                }";
        wp_add_inline_style( 'custom-style', $custom_css );
}
add_action( 'wp_enqueue_scripts', 'my_styles_method' );
?>

In this example the title color of the different section will have the same color

@robbisy robbisy closed this as completed Apr 23, 2016
@robbisy robbisy reopened this Apr 23, 2016
@robbisy robbisy changed the title color picker problem in repeater color picker question in repeater Apr 23, 2016
@Rayken
Copy link

Rayken commented Apr 24, 2016

You can use the array keys as unique identifiers for the rows, see: #908 (comment)

Basically each repeater row gets its own unique index in the array returned by get_theme_mod() so to target one section individually you'd want to add a class or ID to that element containing the key.

@robbisy
Copy link
Author

robbisy commented Apr 24, 2016

Thanks

@robbisy robbisy closed this as completed Apr 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants