Viewing 16 posts - 1 through 16 (of 16 total)
  • Author
    Posts
  • #573732

    Hello,

    Thanks for a great theme!

    Is it possible to add gallery images to the search result in Enfold Theme.

    Regards

    Joel

    #574504

    Hey 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,
    Josue

    #574585

    Thanks for your answer Josue!

    Which do you mean?
    Title, Caption, Alt Text or Description?

    I can´t search on either?

    Regards
    Joel

    #574818

    Yes, search for those metadata, do you get any results? can you post a link to your site?

    Regards,
    Josue

    #575685

    Ok,

    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

    #576309

    Hi!

    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,
    Ismael

    #576324

    Hi,

    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,
    Joel

    #576880

    Hi,

    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,
    Rikard

    #576992

    OK!

    Thanks!
    //Joel

    #577712

    Hey!

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

    #746764

    Hi 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
    Joel

    #749218

    Hey!

    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,
    Ismael

    #749238

    Hi,

    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,
    Joel

    #749709

    Hi!

    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,
    Ismael

    #761336

    Big 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 consolens

    Do you know what could have gonge wrong?

    Best regards,
    Joel

    #762511

    Hi 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_hacked

    Let me know if this was helpful and you will be able to get your site back up and running soon.

    Best regards,
    Victoria

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