[Support request] How to get a preset colour via php

Home Forums Support [Support request] How to get a preset colour via php

Home Forums Support How to get a preset colour via php

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #1508367

    I made some additional changes to layouts using the hooks from elements. I want to be able to just change the colour via the customiser instead of having to go back into elements and use it. The colour would be the same colour for example as the main navigation. Where are those values created / stored? Or does anyone know the php code to reference / pull that colour so I can simply set a value via <style> in elements which would change its colour everytime I changed the navigation colour?

    Customer Support

    Hi there,

    you can use the generate_settings function like so:

    // Generate Custom CSS from existing Customizer settings
    function db_custom_css_output() {
        if ( ! function_exists( 'generate_get_defaults' ) ) {
        $generate_settings = wp_parse_args(
            get_option( 'generate_settings', array() ),
        if ( ! class_exists( 'GeneratePress_CSS' ) ) {
        if ( ! function_exists( 'generate_get_font_family_css' ) ) {
        $css = new GeneratePress_CSS;
        // Get custom CSS properties from database
        // Change Selctor to CSS Class instead of element tag
        // Settings from CSS-output.php 
        $css->set_selector( '.hero-background' );
        $css->add_property( 'background-color', esc_attr( $generate_settings['navigation_background_color'] ) );
        return apply_filters( 'db_custom_css_output', $css->css_output() );
    // Enqueue custom styles within generate-style-inline-css
    add_action( 'wp_enqueue_scripts', function() {
        wp_add_inline_style( 'generate-style', db_custom_css_output() );
    }, 100 );

    For reference:


    Hi. I need something like this too, but I’m not getting the Navigation Text color value. What should I use instead of $generate_settings[‘background_color’]?.

    I tried [navigation_text_color ] but it chooses wrong.

    Element Type > Header > Site Header >Navigation Colors > Navigation Text


    $css->set_selector( '.header-wrap #site-navigation:not(.toggled) .main-nav > ul > li > a, .header-wrap #mobile-header:not(.toggled):not(.navigation-stick) .main-nav > ul > li > a, .header-wrap .main-navigation:not(.toggled):not(.navigation-stick) .menu-toggle, .header-wrap .main-navigation:not(.toggled):not(.navigation-stick) .menu-toggle:hover, .main-navigation:not(.toggled):not(.navigation-stick) .mobile-bar-items a, .main-navigation:not(.toggled):not(.navigation-stick) .mobile-bar-items a:hover, .main-navigation:not(.toggled):not(.navigation-stick) .mobile-bar-items a:focus' );
    $css->add_property( 'color', esc_attr( $options['navigation_text_color'] ) );
    Customer Support

    Hi Onalti,

    I’m sorry but I’m not quite sure I understand what you’re trying to do? To clarify, are you trying to set the Navigation Text color of the Header Element to the one set from the Customizer?

    This may be unnecessary since if you don’t set a color in the Site Header options, by default, the Navigation Text in which this Header element is applied to automatically gets the color from the Customizer. 🙂

    If you’ve already set a color, you’ll simply need to clear it and the color will default back to the one set in the Customizer.

    See this for reference: https://share.getcloudapp.com/12u0gjw7

    Please let us know if we misunderstood something. Thank you! 🙂


    Hi there,
    Yes, you misunderstood the point. David and Tom understood my question.

    Customer Support

    Sorry, I misunderstood. I’m glad that Tom and David are there to help! Let us know if you’ll need help with anything else. Hope you have a nice day! 🙂

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