Site logo

Archived topic

Text over featured image on single *and* archive

3 replies · Started by Bidegato on August 16, 2018

Viewing posts 1–4 of 4

Hello,

I'd like to show text over featured images for a Custom Post Type, both on single posts and archives, based on a given condition (the slug of a custom taxonomy).
Is there any way to accomplish this with GeneratePress?

I'm experimenting whith Wordpress filter "post_thumbnail_html". As far as I know, Wordpress function 'get_the_post_thumbnail()' fires this filter, and I think that GP calls this function both from content.php and content-single.php (through 'generate_before_content' action hook) , but I only see the expected result on single posts, and not on archives.

This is my test code:

<?php
function modify_post_thumbnail_html($html, $post_id, $post_thumbnail_id, $size, $attr) {
        $html .= '<h3>SOME TEXT AFTER FEATURED IMAGE</h3>';
    return $html;
}
add_filter('post_thumbnail_html', 'modify_post_thumbnail_html', 99, 5);
?>

What am I missing?
Or otherwise, Is there any other way to accomplish this (print contidional text over or after featured image on any page it appears on) with GP?

Thank you!

Hi there,

Are you using any of our featured image options in the Blog module? For example, are you resizing your images inside the Customizer?

Any chance you can link me to your site?

Thanks! :)

Hi Tom,

As you looked surprised in your answer, I built a simplified version of my development site, and this time the snippet wrote the text after every featured image, both on single posts and archive. So I have to find a bad interactions with other snippets or plugins in the main development site. Thank you very much for your support.

You said in antoher support thread (https://generatepress.com/forums/topic/how-to-create-an-image-overlay/) that you’ll look into adding a hook inside the post image container, so it would be possible to add a text overlay on featured images with some css. Is it on your roadmap for GP hooks?

thank you!

Yes - I really need to add that hook. Will try to get it done ASAP.

Let me know if you have trouble finding the issue on your production site :)

This archived topic is closed to new replies.