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.

Change Color of Links in Blog Post

  • Hi, I am trying to change the links’ color in the text’s body. However, when I change the color in the customizer, it seems to change the color across other areas of the website, like the recommended articles to read in the sidebar and the author’s name on top. Can I just change the color of the linked content within the blog post only? The color I want to change the text to is called var(–lifestyle)

  • Hi there,

    theres a few ways to do it, i think the simplest here may be some CSS:

    
    .entry-content :is(p,li) a {
        color: var(--lifestyle);
    }
    

    This will apply to just the links within your content that are inside a paragraph or a list.

  • I tried that but it had some unwanted effects https://ibb.co/6B7gKK7

  • I updated the CSS above so it only effects single content.

  • Thank you, that seems to work! When I go to edit a piece, I cannot see any of the links; all of the links are the same color as the text. Is there any way we can include this in the CSS?

  • See my reply here:

    https://generate.support/topic/image-caption-2/#post-91712

    you can use the relevant snippet to load the CSS in the editor

  • This PHP snippet hasn’t worked for me.

  • what is the exact code you used?

    and where did you add the CSS?

  • what is the exact PHP code you used?

    and where did you add the CSS?

  • I added the following into the Code Snippets plugin:

    add_filter( ‘block_editor_settings_all’, function( $editor_settings ) {
    $css = wp_get_custom_css_post()->post_content;
    $editor_settings[‘styles’][] = array( ‘css’ => $css );

    return $editor_settings;
    } );

    The CSS was added to the Customizer additional CSS

  • Sorry my bad – you will need this snippet:

    
    add_filter( 'block_editor_settings_all', function( $editor_settings ) {
      $css = '
      a {
        color: var(--lifestyle) !important;
      }
      ';
      $editor_settings['styles'][] = array( 'css' => $css );
    
      return $editor_settings;
    } );
    

    The reason is the entry-content class in your CSS only exists on the front end.

  • Is this an additional snippet to what I already have or should I replace the current snippet with that one? Currently, I have replaced the previous snippet with that one and it’s not working for me

  • I added the !important part of the snippet and it works now. Thanks a lot!

  • Glad to hear that

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