Home > Enterprise >  Change Events Calendar widget hyperlink colour with custom CSS in WordPress
Change Events Calendar widget hyperlink colour with custom CSS in WordPress

Time:01-22

Have found great help with R on SO--now for something completely different.

I am working in WordPress 5.8.3.

I am building a website using the Blank Canvas theme, a child-theme of Seedlet--Not sure whether that is all relevant. I am a novice with WP and all things web development. I have installed the Events Calendar plugin and have it all configured with some test events and dates so no issues there. I am customizing the theme colours using the Additional CSS prompt from the WordPress dashboard interface.

I haven't gotten permission to publish the site, so unfortunately I can't offer a live demo. I will try to be explicit.

I have found helpful resources with instructions on how to use this utility The link in yellow should be black.

From this image, you can see the Events Calendar hyperlink text is yellow. I opened the inspector and determined that this object is called .tribe-events-widget .tribe-events-widget-events-list__view-more-link. I thought the following code should change the colour

.tribe-events-widget .tribe-events-widget-events-list__view-more-link {
    color:#000;
}

It does not. This code makes no visible change. However, when I also change the background-color like this:

.tribe-events-widget .tribe-events-widget-events-list__view-more-link {
    background-color:black;
    color:#000;
}

The result is:

enter image description here

This led me to believe that there is no colour option for this element---HOWEVER, the inspector shows that this element has the 'color' property:

enter image description here

And I'm stumped. I'm not even sure when or how this color-link-accent got defined. This check-mark toggle is not a permanent solution and besides, I would very much like to understand what is going on here.

Any advice would be greatly appreciated.

CodePudding user response:

It's a bit difficult to be certain of the problem as we don't have the context, however I was surprised that you saw just this:

.tribe-events-widget .tribe-events-widget-events-list__view-more-link

and didn't find an anchor (a) element within it.

I would have expected that you'd have to do:

.tribe-events-widget .tribe-events-widget-events-list__view-more-link a {
    color:#000;
}

as it is quite likely the anchor element will have its own special styling which will override your setting because of the increase specificity.

If that doesn't work then use your browser dev tools inspect facility to find out more about the context of that a element - you may need to give even more hints to the browser on pinning it down.

CodePudding user response:

Well, this would have helped me, so I will post the solution to my question for posterity. I discovered in this question and thread about overriding cascading commands. I still don't understand where the command producing the yellow text in the first place was, but I managed to override it by appending !important in my CSS. The full CSS to turn the text from yellow to black is:

.tribe-events-widget .tribe-events-widget-events-list__view-more-link {
    color:black !important;
}

As I suspected, the context was fine, but there was some other instruction for the colour that I had to override.

Hope somebody else can benefit from my toiling...

  •  Tags:  
  • Related