Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Adding global style

  • Hi there,
    On my website I have set the colours in the customizer and the body text is white for the website. My issue with this is when I go to write a blogpost all the text is white and I need to manually change each colour. How can I add a global style that I can apply to the posts to make the sub titles and body text #090909?

    Thanks 🙂

  • Hi there,

    You can specify the color of the text under the Content option inside the Customizer’s Global Color setting.

  • Hi Alvind, when I do that via colors> content> text (and H2s + H3s) it changes the colours of those H and p throughout the website. I want to specify this only for posts and keep the global colour options set for the rest of the text on the website.

  • In that case, you can use this CSS:

    body.single-post .content-area p,
    body.single-post .content-area h3 {
      color: #090909;
    }

    This will only apply the color to text and sub-title within the post content area.

  • Thank you 🙂 The only problem is still when I write the blog post the text is white, when I publish it will be black but surely there’s a way to negate this?

  • Thank you 🙂 The only problem is still when I write the blog post the text is white, when I publish it will be black but surely there’s a way to negate this? I have the setting to white in body text, I thought I could change content text to white for my post content?

  • The editor does not load CSS you added, so no, the style will not appear in the editor.

    Unless you use a PHP snippet to insert this CSS to the editor, but the CSS need to be modified as the editor does not have .single-post class.

    Try this:

    wp_add_inline_style( 'wp-block-library', 
    '.post-type-post :is(p, h3) {
        color: #090909;
    }' 
    );

    Adding PHP: https://docs.generatepress.com/article/adding-php/

  • thanks Ying, I understand that. My question was more about is my text is set to black for content in the global colours why was it still not showing? What is the difference between content and body for the global colour styling? Thanks

  • The only problem is still when I write the blog post the text is white, when I publish it will be black but surely there’s a way to negate this?

    This is the caveat of this method. If you need to use a different color in the editor for easier editing, you’ll need to change it manually from the Typography block settings. This doesn’t matter much because the frontend result will apply the color that is set in the CSS.

  • thanks, Alvind. I figured as much now 🙂 Could you still answer my question though, what is the difference between content and body for global colour styling? Thanks

  • You’re welcome!

    Basically when you apply styles to body, you’re styling the entire content area of your webpage. This includes backgrounds, fonts, margins, and other properties that affect the overall layout and appearance of the page.

    In your context, the term ‘content’ refers to a more scoped area that specifically relates to the post content area. Therefore, any styles applied here will only affect this area.

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