• Resolved slashedbeauty

    (@slashedbeauty)


    In the builder, the search function doesn’t work to search through existing media library files. I want to use photos from a blog post in 2017, and I’m forced to scroll endlessly to find it because when I search, I get “no results found” for keywords OR if I’m putting in the exact file name as well. This takes so much time from creating, just to locate a file.

Viewing 6 replies - 16 through 21 (of 21 total)
  • Plugin Author Pascal Birchler

    (@swissspidy)

    When performing a media search in the editor, what the browser essentially does is calling https://slashedbeauty.com/wp-json/wp/v2/media?search=<searchterm>. This is WordPress’ built-in REST API for media items. For some reason, searching for media items is not working on your site.

    For example, https://slashedbeauty.com/wp-json/wp/v2/media?search=magnetic should return the contents https://slashedbeauty.com/wp-json/wp/v2/media/19127 (image https://slashedbeauty.com/wp-content/uploads/2021/06/magnetic-lash-review-video-thumbnail.jpg) but it’s simply empty.

    So there’s clearly something off with your site’s setup.

    Since you mention this also happens in Troubleshooting mode with all other plugins disabled, I feel like there’s only two options left:

    1. Use a different theme in Troubleshooting mode (e.g. Twenty Twenty
    2. Reach out to your hosting provider regarding this issue with the REST API. Perhaps there are some security measures implemented or something.

    Hi – Miranda’s developer here.

    The overall REST API is working: https://slashedbeauty.com/wp-json

    Are you saying that the specific API to the media search is disabled somewhere?

    NM we found it. Custom code in functions.php to limit searches to posts only. I removed this and it worked.

    /* EXCLUDE PAGES FROM SEARCH */
    if (!is_admin()) {
    function wpb_search_filter($query) {
    if ($query->is_search) {
    $query->set(‘post_type’, ‘post’);
    }
    return $query;
    }
    add_filter(‘pre_get_posts’,’wpb_search_filter’);
    }

    Plugin Support Luckyna San

    (@luckynasan)

    @mossifer We appreciate your update! @slashedbeauty Thank you for all your patience and help to troubleshoot as well. We’re glad to hear that fixes the issue!

    We will mark your topic as resolved but please don’t hesitate to reach out with a new support topic if you continue to experience any other issues. Thank you!

    I’m not sure why the post search would be affecting your image search since our native image search was working fine. Some themes might have options in the customizer that allow the site owner to choose which types of posts show up in the main search – that may conflict with your code as well.

    Just something to document in case this happens to someone else.

    Plugin Author Pascal Birchler

    (@swissspidy)

    > I’m not sure why the post search would be affecting your image search since our native image search was working fine.

    @mossifer Image search in the WordPress media library happens in the admin, so the code you removed did not affect it (as it only works if ! is_admin()). The REST API is not in the admin, however, so the code did affect it.

Viewing 6 replies - 16 through 21 (of 21 total)
  • The topic ‘Can’t Search through Media Library’ is closed to new replies.