- This topic has 6 replies, 3 voices, and was last updated 5 years, 4 months ago by
Ernst Wilhelm.
-
AuthorPosts
-
December 1, 2020 at 2:50 am #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.
December 1, 2020 at 6:48 am #1560357David
StaffCustomer SupportHi there,
did you try the final code that Tom provided here:
With that applied can you share a link to where i can see the issue?
December 1, 2020 at 7:17 am #1560616Ernst 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
December 1, 2020 at 9:42 am #1561319Tom
Lead DeveloperLead DeveloperJust to confirm, are you wanting your attachments to display their attachment image as their featured image on archive pages?
Let me know 🙂
December 1, 2020 at 10:34 am #1561591Ernst 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
December 2, 2020 at 9:46 am #1564160Tom
Lead DeveloperLead DeveloperHaven’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 );December 2, 2020 at 11:14 am #1564338Ernst 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
-
AuthorPosts
- You must be logged in to reply to this topic.