Wikipedia:Reference desk/Archives/Computing/2017 August 25

= August 25 =

Overriding Default Caption Color in Wordpress Theme
I'm hosting a Wordpress site and using the Enfold theme. I have set the caption color to white, because that's what most of my pages use: however, there are a few pages where I need the caption to be black. How do I override the default caption color for just those pages? I think I can define a new class for that caption, but I'm not sure how to insert it into the page, or how to make sure it is processed after the default style sheets (Wordpress themes have dozens of rules for each element, so I have to insert the new rule in just the right place). OldTimeNESter (talk) 16:02, 25 August 2017 (UTC)
 * If its just a couple of pages you can also use inline styles. Another option is to use a class with !important. The priority of different types of CSS is described over at Cascading_Style_Sheets. If you give me the URL then I can have a look. &#40;&#40;&#40;The Quixotic Potato&#41;&#41;&#41; (talk) 17:42, 25 August 2017 (UTC)

For example: .caption {color:red;} .caption {color:blue;}

Potatoes The caption will be blue because the CSS rules are processed in order.

If we change it to: .caption {color:red;} .caption {color:blue;}

Potatoes then the caption will be green, because inline styles overrule the tag.

But if we change it to: .caption {color:red !important;} .caption {color:blue;}

Potatoes then it will be red, because of the !important.

You can add inline styles (example #2) by editing the HTML of a Wordpress page or post (The WYSIWYG editor has a "Text" tab on the top-right which allows you to edit the HTML).

You can edit the stylesheet of a Wordpress theme by visiting yourdomainname.com/wp-admin/theme-editor.php (replace yourdomainname.com with your domain name). You'll see a bunch of filenames on the right side of the screen, click on the one that is called style.css. This way you can use example #3.

If you make changes to a Wordpress theme stylesheet they will be overwritten the next time you update the theme. The best way to avoid that is using a Wordpress child theme, but explaining how to do that is a bit too much work.

&#40;&#40;&#40;The Quixotic Potato&#41;&#41;&#41; (talk) 18:02, 25 August 2017 (UTC)
 * The Quixotic Potato, thank you for the detailed answer. I'm going to see if I can make this work. OldTimeNESter (talk) 17:37, 28 August 2017 (UTC)