Under what conditions should the border appear?
Currently I have tags attached to posts and the first condition would be:
If this post has tag x then add border.
The second condition is:
If a certain value is above 1 then set the colour as something else.
I can work out how the conditions will function but my PHP/WordPress knowledge is fairly limited so a nudge in the right direction would be more than appreciated.
Thanks
as your theme uses post_class() in the content.php template, you could use a filter on 'post_class' to add a tag specific CSS class or a class if the post has a certain tag.
https://codex.ww.wp.xz.cn/Function_Reference/post_class#Add_Classes_By_Filters
similar with your other condition.
Your theme uses body_class() and post_class(), so there are some CSS classes you could use:
.tag-{slug} .entry-content img {
border: 2px solid orange;
}
.tag-{slug} .entry-content img {
border: 2px solid green;
}
where {slug} is the name of the tag, with all punctuation removed, spaces converted to hyphens, and all letters converted to lowercase.
For your second condition, would something like this work:
<?php
if ( $certain_value > 1 ) {
$border_color = "orange";
else {
$border_color = "green";
}
?>
<img src="/path/to/image" style="border: 1px solid <?php echo $border_color; ?>">
Hey all, sorry for late reply, gmail puts WordPress into social so I don’t get the notification meh.
Thanks for the assistance, was not expecting such a rapid response.
All makes sense, don’t see any reason why it wouldn’t work, will set it up when I get home later and let you know the good news.
Thanks again, much appreciated.