[Resolved] Text over featured image on single *and* archive

Home Forums Support [Resolved] Text over featured image on single *and* archive

Home Forums Support Text over featured image on single *and* archive

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #650805
    Bidegato

    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!

    GeneratePress 2.1.3
    GP Premium 1.7.1
    #650978
    Tom
    Lead Developer
    Lead Developer

    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! 🙂

    #652550
    Bidegato

    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!

    #652883
    Tom
    Lead Developer
    Lead Developer

    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 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.