Site logo

[Support request] customize default colors via css

Home Forums Support [Support request] customize default colors via css

Home Forums Support customize default colors via css

Viewing 15 posts - 1 through 15 (of 19 total)
  • Author
    Posts
  • #2490639
    sparkle

    if i put this in my customizer, the colors change on the page, but not in the customizer circles.

    :root {
    –contrast: #09283D;
    –contrast-2: #025547;
    –contrast-3: #a9d4cd;
    –base: #f0f0f0;
    –base-2: #1A878E;
    –base-3: #81fce7;
    –accent: #DC3BA1;
    }

    if i put it in my child theme, neither change, even if i add !important. why not? any way to have it all? there used to be function that no longer seems to work that set custom default colors and the customizer reflected the changes.

    // change gp color palette
    
    add_filter( 'generate_default_color_palettes', 'tu_custom_color_palettes' );
    function tu_custom_color_palettes( $palettes ) {
      $palettes = array(
    
        '#351C4D', /* brand */
        '#FEBF7B', /* accent */
        '#FF7E5F', /* action */
        '#765285', /* hover */
        '#C1c1c1', /* light */
        '#fe7b84', /* midtone */
        '#000000', /* black */
        '#FFFFFF', /* white */
      );
      
      return $palettes;
    }
    #2491623
    David
    Staff
    Customer Support
    #2491778
    sparkle

    well, i did find and try that code, but for some reason it doesn’t work for me. subscriber credentials included below. let me know if you need more access to tell me what i did wrong. it’s the only thing in my functions file.

    #2492118
    Leo
    Staff
    Customer Support

    Just to confirm, are you using the new global colors system?
    https://docs.generatepress.com/article/global-colors-overview/

    And can you try adding the code using Code Snippets plugin with the parent theme activated?

    Let me know 🙂

    #2492819
    sparkle

    yes, it’s a brand new install and i see the global colors system in my customizer.

    i removed the code from my functions file, installed code snippets, added it, saved it, no change, activated it, no change. double checked parent theme vs child theme. weirdly i can see the new colors in the customizer now, but not on the pages. even with incognito.

    then i gave your username admin access because i’m seriously confuzzled.

    #2492825
    sparkle

    ok. with a little patience the cache on the front end let go and now i see the colors with the code snippet.

    #2493019
    sparkle

    but why can’t i do anything with my child theme? rawr. i don’t want to use code snippets.

    #2493112
    David
    Staff
    Customer Support

    Can you retry adding the code to the Child Theme functions.php ?

    #2493181
    sparkle

    ok. it’s there now.

    #2493196
    sparkle

    fyi, i have the child theme one set like this to see the difference.

     add_filter( 'generate_option_defaults', function( $defaults ) {
         $defaults['global_colors'] = array(
             array(
                 'name' => __( 'Contrast', 'generatepress' ),
                 'slug' => 'contrast',
                 'color' => 'red',
    #2493199
    sparkle

    aaaand… i can see the red in the customizer but not the live site even if i deactivate code snippets (which i almost never use, will that disable it or not?

    #2493372
    Leo
    Staff
    Customer Support

    The function here looks incomplete:
    https://generatepress.com/forums/topic/customize-default-colors-via-css/#post-2493196

    Can you try the exact code here in the child theme?
    https://generatepress.com/forums/topic/changing-global-colors-programatically/#post-2122087

    Please clear and disable all caching plugins and server caching for now.

    #2493382
    sparkle

    oh that was just the one part of it that i changed the color so it was different from the one in the code snippet plugin. it shows the titles red if it’s using the function.file. the full code in my child theme is this

    //gp change color palette
     
     add_filter( 'generate_option_defaults', function( $defaults ) {
         $defaults['global_colors'] = array(
             array(
                 'name' => __( 'Contrast', 'generatepress' ),
                 'slug' => 'contrast',
                 'color' => 'red',
             ),
             array(
                 /* translators: Contrast number */
                 'name' => sprintf( __( 'Contrast %s', 'generatepress' ), '2' ),
                 'slug' => 'contrast-2',
                 'color' => '#025547',
             ),
             array(
                 /* translators: Contrast number */
                 'name' => sprintf( __( 'Contrast %s', 'generatepress' ), '3' ),
                 'slug' => 'contrast-3',
                 'color' => '#a9d4cd',
             ),
             array(
                 'name' => __( 'Base', 'generatepress' ),
                 'slug' => 'base',
                 'color' => '#f0f0f0',
             ),
             array(
                 /* translators: Base number */
                 'name' => sprintf( __( 'Base %s', 'generatepress' ), '2' ),
                 'slug' => 'base-2',
                 'color' => '#1A878E',
             ),
             array(
                 /* translators: Base number */
                 'name' => sprintf( __( 'Base %s', 'generatepress' ), '3' ),
                 'slug' => 'base-3',
                 'color' => '#81fce7',
             ),
             array(
                 /* custom colors */
                 'name' => __( 'Hot Pink', 'generatepress' ),
                 'slug' => 'sub-hot-pink',
                 'color' => '#BF047E',
             ),
             array(
                 'name' => __( 'Teal', 'generatepress' ),
                 'slug' => 'sub-teal',
                 'color' => '#32838C',
             ),
             array(
                 'name' => __( 'Aqua', 'generatepress' ),
                 'slug' => 'sub-aqua',
                 'color' => '#04BF9D',
             ),
             array(
                 'name' => __( 'Yellow', 'generatepress' ),
                 'slug' => 'sub-yellow',
                 'color' => '#DC3BA1',
             ),
             array(
                 'name' => __( 'Orange', 'generatepress' ),
                 'slug' => 'sub-orange',
                 'color' => '#D94423',
             ),
         );
         return $defaults;
     } );
         
    
    #2494508
    David
    Staff
    Customer Support

    When you say you see it in the Customizer – is that just in the Global Color pallet?
    If so, that is correct – that code only loads the default colors, you would need to then assign them where you require.

    #2494544
    sparkle

    ah… so an image is worth 1000 words here.

    customizer shows functions file (red)
    https://imgur.com/w7l0fjA

    live view does not. even in incognito. var contrast stays black.
    https://imgur.com/vUcej38

    does disabling code snippets plugin remove the snippets from use?

Viewing 15 posts - 1 through 15 (of 19 total)
  • You must be logged in to reply to this topic.