-
caitrionam96
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.
-
caitrionam96
I tried that but it had some unwanted effects https://ibb.co/6B7gKK7
-
I updated the CSS above so it only effects single content.
-
caitrionam96
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
-
caitrionam96
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?
-
caitrionam96
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. -
caitrionam96
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
-
Remove the snippet from this topic:
https://generate.support/topic/change-color-of-links-in-blog-post/#post-91721And add the new one.
-
caitrionam96
I added the !important part of the snippet and it works now. Thanks a lot!
-
David
Glad to hear that
- You must be logged in to reply to this topic.