Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1256387

    Hey there,

    we had a working solution to show images in wordpress -search. Now without any changes its not working anymore.
    This is the code we used in our functions:

    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' );

    For example u can search for the images on frontpage like: “mw4”.

    I hope u can help.

    Beste regards

    L

    • This topic was modified 3 years, 8 months ago by snorlachs.
    #1257090

    Hey snorlachs,

    Please have a look at the following thread:
    https://kriesi.at/support/topic/show-featured-images-in-search-results-page/

    If you need further assistance please let us know.

    Best regards,
    Victoria

    #1257110

    Hello Victoria,

    thank you for the answer.

    In our case we dont need a solution to search for featured images, we need a solution to search for images (by image-titles) used in galleries uploaded to the library. Is it possible to change this code to show pictures from library by searching for the image-title?
    Sorry i tried my best but im not that familiar with php…

    $searchimage = get_the_post_thumbnail( $the_id, 'large' );
    echo "<span class='search-result-image'>{$searchimage}</span>";
    echo "<span class='search-result-counter {$counterclass}'>{$post_loop_count}</span>";

    Best regards

    L

    #1257178

    Hi snorlachs,

    Unfortunately, it would require quite some time and customization of the theme to achieve this, so I am sorry to tell you that this is not covered by our support. However, if it’s really important for you to get this done, you can always hire a freelancer to do the job for you or look for a plugin that has that option :)

    Best regards,
    Victoria

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