Site logo

[Support request] Featured Image Attachment Page

Home Forums Support [Support request] Featured Image Attachment Page

Home Forums Support Featured Image Attachment Page

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1560056
    Ernst Wilhelm

    It is possible to assign a featured image to an attachment page manually. So an image can be its own featured image on its own attachment image.

    How can I get this with an ‘automatic process’? There are several searching plugins out in the fields which allows searching for images but they show images only for a post only in case of an existing image.

    Is this clear and can you help me in this?

    I’ve tried the code snippets already provided in request https://generatepress.com/forums/topic/how-to-show-images-attachments-in-search-results/ . Not successful, no image.

    #1560357
    David
    Staff
    Customer Support

    Hi there,

    did you try the final code that Tom provided here:

    https://generatepress.com/forums/topic/how-to-show-images-attachments-in-search-results/#post-1004354

    With that applied can you share a link to where i can see the issue?

    #1560616
    Ernst Wilhelm

    Hi. Yes I did. The code is embedded in the child functions.php. The child theme is activated.

    Searching for the string slider 15 attachments are found (ok). One of them is showing a featured image which I assigned manually.

    https://test.r-mediabase.eu/?s=slider

    Thank you, Ernst-Wilhelm

    #1561319
    Tom
    Lead Developer
    Lead Developer

    Just to confirm, are you wanting your attachments to display their attachment image as their featured image on archive pages?

    Let me know 🙂

    #1561591
    Ernst Wilhelm

    Hi Tom.

    Are you wanting your attachments to display their attachment image as their featured image on archive pages?

    So far I have not thought about archive pages, my priority is the display in search results.

    Beyond that. Yes that’s it. Thanks for asking.

    Ernst-Wilhelm

    #1564160
    Tom
    Lead Developer
    Lead Developer

    Haven’t found much in my searches for this.

    One idea.. not sure it will work:

    add_filter( 'post_thumbnail_html', function( $html, $post_id ) {
        if ( 'attachment' === get_post_type( $post_id ) ) {
            $html = wp_get_attachment_image();
        }
    
        return $html;
    }, 10, 2 );
    #1564338
    Ernst Wilhelm

    Hi. Many thanks for your support. No. It’s not working. That’s the only code piece, right? We can close this support topic but I am also willing to go on with another try.

    Ernst-Wilhelm

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