Get Primary color in a custom CSS

Dear AThemes, dear All,

I created a child theme base on Sydney (free version)
I m in multisite environment (subdomains)

I’ve added some functionalities and widgetsafterwards with custom classes in the child theme .css file.

I d like to have some classes to get the primary color i’ve defined like it does "automatically with "basic widget (i.e. the sydney contact info get the primary colors correctly)

The fact is that I need to get the primary color of each site (using a different color each…)

THanks in adavance for any help.



You’ll have to check /inc/styles.php. There you’ll find $primary_color and see how it’s applied, then you can create your own function to apply it to the CSS classes you need.

This is in case you need it to happen dynamically in case the primary color changes, which I assume you do. Otherwise you could just add the color in the CSS directly.

Thanks Vlad, ot seems that this is what i need.

The Classes i need for the moment (for the example) are :
.top-header-widgets .widget a

When I insert them in the “sydney/inc/styles.php” file, it works perfectly (once i’ve settled color to d65050 in my “/childtheme/style.css” file)

BUT…there’s always a “but” … when i try to insert the function in the “/childtheme/functions.php” file (see added code below), it doesn t work anymore :frowning: … the classes act with the d65050 color settled in style.css

hope you can maybe help me.

Thanks in advance.

function sydney_child_01_custom_styles($custom) {

	$custom = '';
	//Primary color
	$primary_color = get_theme_mod( 'primary_color', '#d65050' );
	if ( $primary_color != '#d65050' ) {
	$custom .= ".top-header-widgets .widget a, .site-title-top:hover { color:" . esc_attr($primary_color) . "}"."\n";

//Output all the styles
	wp_add_inline_style( 'sydney-style', $custom );	

add_action( 'wp_enqueue_scripts', 'sydney_child_01_custom_styles' );

I’d have to see the site, but I guess it’s a question of priority. Try doing it like this:

add_action( 'wp_enqueue_scripts', 'sydney_child_01_custom_styles', 12 );


It works really great

Many many many thanks for your help


(by the way site is: + subdomains sites in “topnav”)