I don’t think the image caption works with “full screen” featured images. For those kinds of images, in all themes, we have always simply put the caption in the body of the text. I’m sure Lucian or Marius will help in how to perhaps modify how that works for you.
This is what my solution in functions.php looks like (adapted from a stackoverflow thread). It looks like this: http://themedium.ca/arts/visual-studies-art-through-snail-mail
I removed the icon code here because you don’t have the assets or the CSS on your end, but if you want it, just ask.
// Show captions on template 4
// adapted from stackoverflow.com/questions/13850313/how-to-add-a-featured-image-caption-in-wordpress
function get_template4_caption($post) {
$thumbnail_id = get_post_thumbnail_id($post->ID);
$thumbnail_image = get_posts(array('p' => $thumbnail_id, 'post_type' => 'attachment'));
if ($thumbnail_image && isset($thumbnail_image[0]) && $thumbnail_image[0]->post_excerpt) {
return '<div class="template_4_caption"><span class="td-block-author"> . $thumbnail_image[0]->post_excerpt .'</div></span>';
}
}
In order to have it below the image, the function is called in single_template_4.php in each of the three sidebar cases, e.g. the last line here:
<?php
// we check the sidebar position and for each one we have a different case
switch ($loop_sidebar_position) {
default: // sidebar right - the default sidebar position
echo td_page_generator::wrap_start();
?>
<div class="span8 column_container td-post-content" role="main" itemprop="mainContentOfPage">
<?php echo get_template4_caption($post); ?> <!-- new -->
Note that you might still want to add some CSS styling for template_4_caption or whatever classes you choose to use, e.g. some margin-top to distance it from the image.
If you wanted it on the image like the rest of the meta info, you would have to adjust this placement and the styling.
The function have a syntax error. The right code is this:
return '<div class="template_4_caption"><span class="td-block-author">' . $thumbnail_image[0]->post_excerpt . '</div></span>';
I call the function in the single_template_3:
<figcaption class="wp-caption-text" style="position:relative; bottom: 30px;">
<?php echo get_template4_caption($post); ?>
</figcaption>
I added the code bellow the “close the row from td_page_generator” closing div. Despite the style that I apply inline, the layout is slightly different of the standard template (http://www.acege.net/acege/porque-sai-da-nike-alexandra-machado-na-acege-faro/). What I should change to match the formatting?
Hi,
You can add and use the css in theme panel > custom css: http://screencast.com/t/sM1w04zHxM
.wp-caption-text {
position: relative;
bottom: 30px;
color: red;
}
Thanks
Whoops, yeah, span should have been closed before div! And I deleted that single quote accidentally. đ Good catch.