Although some images are self-explanatory, many require a note about their contents in order to be relevant to the surrounding article. Luckily, this functionality is baked into WordPress, allowing users to enter a short caption when uploading an image.
These captions are marked up with a special format, and can be styled appropriately quite easily.
For this recipe, you need to have a basic theme created already. This should include a page.php
or single.php
file that displays full post content.
First, we need to open the theme's style.css
file and place our cursor just after the introductory comment.
Then, insert the following class declarations:
.wp-caption { border: 1px solid #ddd; text-align: center; background-color: #f3f3f3; padding-top: 4px; margin: 10px; border-radius: 3px; } .wp-caption img { margin: 0; padding: 0; border: 0 none; } .wp-caption p.wp-caption-text { font-size: 11px; line-height: 17px; padding: 0 4px 5px; margin: 0;...