-
AuthorPosts
-
January 28, 2016 at 2:14 pm #573732
Hello,
Thanks for a great theme!
Is it possible to add gallery images to the search result in Enfold Theme.
Regards
Joel
January 29, 2016 at 1:29 pm #574504Hey Joel!
Gallery images are technically attachments and they should be search-able if you look for their metadata, which you can change for each attachment in Media > Library.
Best regards,
JosueJanuary 29, 2016 at 3:20 pm #574585Thanks for your answer Josue!
Which do you mean?
Title, Caption, Alt Text or Description?I can´t search on either?
Regards
JoelJanuary 29, 2016 at 10:44 pm #574818Yes, search for those metadata, do you get any results? can you post a link to your site?
Regards,
JosueFebruary 1, 2016 at 11:54 am #575685Ok,
I have just put in 1 picture in a gallery so i could try it.
The name of the picture is “Vitsippa” and is placed under “Produkter”.Big thanks
Joel
- This reply was modified 8 years, 9 months ago by Momentummediaab.
February 2, 2016 at 8:56 am #576309Hi!
Please add this in the functions.php file:
function attachment_search( $query ) { if ( $query->is_search ) { $query->set( 'post_type', array( 'post', 'attachment' ) ); $query->set( 'post_status', array( 'publish', 'inherit' ) ); } return $query; } add_filter( 'pre_get_posts', 'attachment_search' );
If you search for the title of the image, it will return the attachment page, not the page where you place the gallery. The solution is to add contents / keywords that is same as the title of the images.
Or use this plugin then enable the attachment post type:
https://wordpress.org/plugins/relevanssi/
http://kriesi.at/documentation/enfold/use-relevanssi-in-search-instead-of-the-default-search/Best regards,
IsmaelFebruary 2, 2016 at 9:21 am #576324Hi,
When I add it to function.php I get this error:
Parse error: syntax error, unexpected ‘&’ in /home/defour/public_html/wp-content/themes/enfold-child/functions.php on line 17
Relevanssi
Where should I put this code: http://kriesi.at/documentation/enfold/use-relevanssi-in-search-instead-of-the-default-search/?In the function.php?
Best regards,
JoelFebruary 3, 2016 at 5:47 am #576880Hi,
Please send us a temporary admin login so that we can have a closer look. You can post the details in the Private Content section of your reply.
Best regards,
RikardFebruary 3, 2016 at 9:26 am #576992OK!
Thanks!
//JoelFebruary 4, 2016 at 12:02 pm #577712Hey!
Please copy the codes directly from the forum, not from your email. We added the code in the functions.php file. The attachment or image page should be searchable now.
Cheers!
IsmaelFebruary 14, 2017 at 9:24 am #746764Hi again and thanks for the help,
Is it possible to get the search with a picture preview? Like instead of the number on the left side?
Big thanks and best regards
JoelFebruary 20, 2017 at 9:12 am #749218Hey!
This is possible but you have to modify the search template. Example here:
// https://kriesi.at/support/topic/add-featured-image-to-search-results/#post-249161
Regards,
IsmaelFebruary 20, 2017 at 9:46 am #749238Hi,
Thank you for the answer but I did not work for me… The search are including images but they doesn’t appear in the preview. Do you know why?
Best regards,
JoelFebruary 21, 2017 at 5:09 am #749709Hi!
Please replace the line with the following code instead:
$type = get_post_type($the_id); $searchthumb = $type == 'attachment' ? wp_get_attachment_image_src( $the_id ) : get_the_post_thumbnail_url( $the_id, 'large' ); $searchthumb = $type == 'attachment' ? $searchthumb[0] : $searchthumb; echo "<span style='background: url({$searchthumb}); background-size: cover;' class='search-result-counter {$counterclass}'></span>";
Best regards,
IsmaelMarch 15, 2017 at 12:00 pm #761336Big Thanks for the help!
I have another question: after we did this my site has been acting weird:
– Google has marked it as it might been hacked
– I can´t reach some parts of the backend
– I can´t connect with google search consolensDo you know what could have gonge wrong?
Best regards,
JoelMarch 17, 2017 at 2:45 pm #762511Hi Momentummediaab,
That’s not good.
Here are two pages where you can learn more on how to proceed.
https://www.wordfence.com/learn/has-my-site-been-hacked/
https://codex.wordpress.org/FAQ_My_site_was_hackedLet me know if this was helpful and you will be able to get your site back up and running soon.
Best regards,
Victoria -
AuthorPosts
- You must be logged in to reply to this topic.