Site logo

Archived topic

Image Post Caption in Page Header

8 replies · Started by Kevin on May 29, 2018

Viewing posts 1–9 of 9

I use people's illustrations for the headers of the articles.

I wanted to put the caption of the images in Page Header, but there is no tag for that. How can I create a tag or shorcode?

Hi there,

Not sure if I understand.

Caption of which images? Any examples you can provide?

Let me know :)

I want a code that shows the Caption of the highlighted image of the article in Page Header. So I can put the credits of the author of the image along with the author of the same article in the example below:

null

The big problem is that I would have to add every time, I use the same illustration in several posts, it is annoying to have to add a custom field, being that I can only once add in the Caption of the media. My old theme did this automatically in the Header. Maybe if creating a shortcode is enough, but I do not know how, I do not know anything about PHP.a

I was able to create the shortcode, it was simple:

add_shortcode('autor-imagem', 'thumbnail_in_content');

function thumbnail_in_content($atts) {
    global $post;

    return get_the_post_thumbnail_caption($post->ID);
}

Tom / Kevin,

this is a shortcode i was playing with a while back, it grabs the featured image caption. It works inside the page header, just couldn't get it to appear inside of the the page header content area:

function db_featured_image_caption() {
    $get_description = get_post(get_post_thumbnail_id())->post_excerpt;
    if(!empty($get_description)){    
        echo '<div class="featured_caption">' . $get_description . '</div>';
    }
}
add_shortcode ('featured-caption', 'db_featured_image_caption' );

EDIT - Didn't see your reply Kevin. Good to see you have something working

Thanks xD

With shorcode that I created I was able to put like this:

https://skdesu.com/lista-de-nomes-japoneses-masculinos/

<span class="titulo-artigo3">Post by {{post_author}} // Art by [autor-imagem]</span>

Now I will try to add a CSS color for each category post... It is good puzzle.

This archived topic is closed to new replies.