Is it possible to pull images from the wordpress media liberary into the search results

Hey there folks

I am looking for a search option that allows users to search for images by the title and or description on a page? I am using wordpress and have set up a 5 galleries and need to enable users to find images by title or description. Will I be able to use Algolia for this?

thanks in advance

Hi @lindamacdonalde,

Welcome to the Algolia Community!

We have documentation about adding additional content from WordPress in our WordPress Integration Guide.

You could pull in the image url’s to your Algolia index.

To get the images from your media library, you could use something like this:

$query_images_args = array(
    'post_type'      => 'attachment',
    'post_mime_type' => 'image',
    'post_status'    => 'inherit',
    'posts_per_page' => - 1,

$query_images = new WP_Query( $query_images_args );

$images = array();
foreach ( $query_images->posts as $image ) {
    $images[] = wp_get_attachment_url( $image->ID );

Hey there Cindy :slight_smile: thank you so much for getting back to me on this and I do apologize for the late reply. will this code let people stay on the page where an image gallery is placed? the images are stored in the wp media liberary and are given a title and alt text there. what I need is to inable people to sift through an image gallery with large amounts of images and actually stay on the image gallery page without being redirected to the backend or a post…is this possible with algolia?

HI @lindamacdonalde,

This will totally depend on what information you store in your Agolia index from your media gallery and what information you provide from that index on your search page. You can provide whatever information you want to your index and then display any information from that index to your user. You can build the links on index time or on your frontend. The above was just an example. You can change that example to include any information or links you’d like to go into your Agolia index.