-
AuthorPosts
-
November 16, 2022 at 7:38 pm #1372834
Is it possible to add wordpress featured images to search results? Thanks.
November 17, 2022 at 3:55 am #1372881Hey Illingco,
Thank you for the inquiry.
You can try the solution that we provided in an older thread to disable the search counter in the search results and replace it with the featured image.
// https://kriesi.at/support/topic/add-featured-image-to-search-results/#post-249161
To adjust the the style, please refer to this modification.
// https://kriesi.at/support/topic/change-layout-search-results/#post-1359284
Best regards,
IsmaelNovember 17, 2022 at 4:08 pm #1372955OK that might work, but what happens when the theme is updated? It just gets overwritten again? I am running Enfold-Child, but there are no include folders there like there are in this main includes folder.
November 18, 2022 at 10:12 am #1373053Hi,
Thank you for the update.
You can create a copy of the includes > loop-search.php file in your child theme to override the default template in the parent theme and keep the modification after an update. Let us know if the modification works.
Best regards,
IsmaelDecember 9, 2022 at 9:31 pm #1375721OK, i followed all that with the following PHP code and CSS, but my results are not ideal. The text tables get jumbled together as linked in private content. Please advise.
PHP
$searchthumb = get_the_post_thumbnail( $the_id, ‘square’ );
if( ! empty( $searchthumb ) ) {
echo “<span class=’search-result-image’>{$searchthumb}</span>“;CSS
#top.search-results .search-result-counter {
padding: 0;
}
#top.search-results .search-result-counter img {
border-radius: 0;
height: 100%;
}
#top.search-results .search-result-counter {
height: 215px;
width: 215px;
background: transparent;
}
#top.search-results .template-search.content .entry-content-wrapper {
height: 215px;
}
#top.search-results #main .post-meta-infos {
display: none;
}
#top.search-results .entry-content,
#top.search-results .post-title {
margin-left: 150px;
}
#top.search-results .post-entry {
padding-bottom: 20px;
}.search-result-image {
display: block;
}
.search-result-image img {
width: 120px;
border: 1px solid #e1e1e1
}
a.slide-image.search_image {
overflow: visible !important;
}
a.search_image .image-overlay.overlay-type-extern {
left: 0 !important
}December 9, 2022 at 9:36 pm #1375722Search on mobile is jumbled too.
December 9, 2022 at 10:50 pm #1375729Update: used PHP above and just this CSS, seems the best I can do, and I cannot get pictures left of text tables, so please lmk what you think.
.search-result-image {
display: block;
}
.search-result-image img {
width: 120px;
border: 1px solid #e1e1e1
}
a.slide-image.search_image {
overflow: visible !important;
}
a.search_image .image-overlay.overlay-type-extern {
left: 0 !important
}December 11, 2022 at 12:22 am #1375806Hi,
To place the images on the left side of the tables please try this css:.template-search .post-entry .entry-content-wrapper { display: flex; } .template-search .post-entry .entry-content-wrapper .entry-content-header { display: flex; flex-direction: column-reverse; align-items: center; justify-content: flex-end; width: 50%; } .template-search .post-entry .entry-content-wrapper .entry-content { display: flex; width: 50%; }
After applying the css, please clear your browser cache and check.
Please see the screenshot in the Private Content area of the expected results.Best regards,
MikeDecember 12, 2022 at 5:01 pm #1375972Thanks Mike. but that’s not ideal either. Can the title be on the right with the table too? And how will this render on mobile? I suspect poorly? Appreciate the help.
December 12, 2022 at 8:40 pm #1375991Hi,
Sorry that this was not helpful, the title and image are in the same div. Perhaps you should leave the image above and just center it as that will be the best layout for mobile.Best regards,
MikeDecember 12, 2022 at 11:27 pm #1376001So to be clear, I should stick with this CSS?
.search-result-image {
display: block;
}
.search-result-image img {
width: 200px;
border: 1px solid #e1e1e1
}
a.slide-image.search_image {
overflow: visible !important;
}
a.search_image .image-overlay.overlay-type-extern {
left: 0 !important
}December 13, 2022 at 12:02 am #1376005n/a
- This reply was modified 2 years ago by Illingco.
December 13, 2022 at 1:52 am #1376013Hi,
If you want to show the image it did look good, I just checked again and now there are no images but numbers instead and that looks good also.Best regards,
MikeDecember 13, 2022 at 5:17 pm #1376064So I did the below, and like this look best, but is there any way to make the image linked to the same as the title next to it? Thanks!
Replace it with:
$searchthumb = get_the_post_thumbnail( $the_id, ‘large’ );
echo “<span class=’search-result-counter {$counterclass}’>{$searchthumb}</span>”;Add this on Quick CSS or custom.css:
.search-result-counter {
padding: 0;
width: 75px;
height: 75px;
}.search-result-counter img {
width: 100%;
height: 100%;
border-radius: 100px;
}#top.search-results .entry-content,
#top.search-results .post-title {
margin-left: 45px;
}December 13, 2022 at 7:37 pm #1376075Also, can I make the thumbnails square at all?
December 13, 2022 at 8:16 pm #1376086Hi,
To make the image square try this css:#top.search-results .search-result-counter { border-radius: unset; }
After applying the css, please clear your browser cache and check.
Best regards,
MikeDecember 13, 2022 at 8:20 pm #1376089That works for making them square, thanks! Any way to make the image linked as the titles are? Thanks for your support.
December 15, 2022 at 1:58 pm #1376268Hi,
To add a link to the image please see this thread that Ismael linked to above, Guenni007 shared adding a link.Best regards,
MikeDecember 15, 2022 at 4:08 pm #1376277Yes but I want to keep what is already shown as is, and it appears his PHP modification would change that or result in errors that show nothing. Please advise further. Thanks.
December 15, 2022 at 7:18 pm #1376286Hi,
As I understood you had already modified the loop-search.php to get your current results, correct?
The change is the same line of code with a link added, isn’t it? Please check your modification carefully.
Please copy your php file to DropBox and link to it so we can check, also include the css needed for the customization in your DropBox link.Best regards,
MikeDecember 15, 2022 at 7:22 pm #1376287I modified loop-search.php as such, and seems to work on staging and live site as I had hoped. Is this correct?
$searchthumb = get_the_post_thumbnail( $the_id, ‘large’ );
echo “<span class=’search-result-counter {$counterclass}’>{$searchthumb}</span>“;Also, these have a child theme, so simpler. How might I implement this in our other Enfold site that does NOT use a child theme? Thanks!
December 15, 2022 at 7:26 pm #1376289Hi,
You will want to use a child theme otherwise the modification will be lost with each update.Best regards,
MikeDecember 15, 2022 at 7:33 pm #1376290That’s what I thought. No way to use snippets or something similar?
How does my PHP mod look?
December 15, 2022 at 7:52 pm #1376294Hi,
Correct you will need to use a child theme, your PHP mod looks good.
Unless there is anything else we can assist with on this issue, shall we close this then?Best regards,
MikeDecember 15, 2022 at 7:55 pm #1376295Yes, unless there is a way to convert a site from a main install of enfold to a child install of it?
December 15, 2022 at 8:14 pm #1376299Hi,
Read about using a Child Theme, when you install the child theme and go to the theme import / export options it will ask you if you want to import the parent theme settings, then all settings and customizations will be added to the child theme.
If this is for a live site and you are worried about the outcome, try first creating a staging site to test on, most cPanel webhosts have a staging site option, some in the dashboard:
Others add the option in the Softaculous WordPress Management
There may be other staging site options in different cPanel servers, these are the two that I have seen.Best regards,
MikeDecember 15, 2022 at 9:05 pm #1376301I tried to install and import from main to activate the child theme instead of main. It changes some things like menus and footers even after import, so it does not appear that will work very well.
- This reply was modified 2 years ago by Illingco.
December 16, 2022 at 1:12 pm #1376397Hi,
Try deactivating the Enfold Theme Options ▸ Performance ▸ JS & CSS file merging and compression and activating Enfold Theme Options ▸ Performance ▸ Delete old CSS and JS files and the clearing your browser and any plugin cache.
If you continue to have trouble, please create a new staging copy of your main site with no child theme and post the admin login in the Private Content area so we can add the child theme and import the theme settings to see why it is not working as expected.Best regards,
MikeDecember 16, 2022 at 1:13 pm #1376399Hi,
Try deactivating the Enfold Theme Options ▸ Performance ▸ JS & CSS file merging and compression and activating Enfold Theme Options ▸ Performance ▸ Delete old CSS and JS files and the clearing your browser and any plugin cache.
If you continue to have trouble, please create a new staging copy of your main site with no child theme and post the admin login in the Private Content area so we can add the child theme and import the theme settings to see why it is not working as expected.Best regards,
MikeDecember 16, 2022 at 6:59 pm #1376438Odd, but I think I got it working. I had “Enfold Theme Options ▸ Performance ▸ Delete old CSS and JS files” enabled prior to installing child theme. I had to toggle that off, save, then toggle on, and clear cache for it to “catch”. The top small menu seems bolded more than the previous, and I had to redo a column in footer widgets, but otherwise looks pretty good on staging. You may verify between the two if you want to see if there are any differences that may cause issues or site failure. Thanks.
-
AuthorPosts
- The topic ‘Display images in search’ is closed to new replies.