Home Support Total How to make the Theme Primary Color in Total work with added child CSS

This topic contains 1 reply, has 1 voice, and was last updated by  TickyNucker 1 week ago.

  • Author
    Posts
  • #3410

    TickyNucker
    Participant

    I have added

    #ht-site-navigation .fa {
    color: #FFC107;
     line-height: 36px;
    }

    to my child-theme style.css. How do I get the Total theme to change my added css to the chosen primary color. If i add the code to the total/inc/style.php it works, but how do I make it work in my child theme?

    I tried adding this code to my child’s function.php but it did not work.

    function total_child_dymanic_styles(){
    	$color = get_theme_mod( 'total_template_color', '#FFC107' );
    	$color_rgba = total_hex2rgba($color, 0.9);
    	$darker_color = totalColourBrightness($color, -0.9);
    	$custom_css = "
    #ht-site-navigation .fa
    {
    	color:{$color};
    }
    ";
        return punte_css_strip_whitespace($custom_css);
    }
    • This topic was modified 2 weeks ago by  TickyNucker.
  • #3434

    TickyNucker
    Participant

    Figured out how to do it!

    Made my own “style.php” file in my child theme and placed it in the same file structure as in the parent theme: /inc/style.php
    This is what’s in the file:

    <?php
    /**
     * @package Total-child
     */
    
    function totalchild_primary_color(){
    	$color = get_theme_mod( 'total_template_color', '#FFC107' );
    	$custom_css = "
    	#ht-site-navigation .fa {
    	color:{$color};
    	}
    	";
    return punte_css_strip_whitespace($custom_css);
    }

    In my function.php (in the childtheme) I call this file:
    require get_stylesheet_directory() . '/inc/style.php';

    and add an in-line-style:

    function my_scripts_styles() {
    	wp_enqueue_script( 'jquery-search', get_stylesheet_directory_uri() . '/js/jquery.search.js', array('jquery') );
    	$parent_style = 'total-style'; // This is 'total-style' for the Total theme.
    	wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
    	wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( $parent_style ), wp_get_theme()->get('Version') );
    
    	wp_add_inline_style( 'child-style', totalchild_primary_color() );
    }
    add_action( 'wp_enqueue_scripts', 'my_scripts_styles' );

    Done!

You must be logged in to reply to this topic.