• Hi,

    I installed the plugin Enhanced Media Library, created some media categories and put the media files in the media categories. How can I exclude all media files of a certain media category from the search?

    When I hover a media category in the admin area, the link looks like this
    /wp-admin/edit-tags.php?action=delete&taxonomy=media_category&tag_ID=90&_wpnonce=8764bd87fc

    So I typed in the category ID of the media category here:
    Settings –> Relevanssi –> Exclude these categories from search
    Settings –> Relevanssi –> Exclude these tags from search

    Unfortunately it doesn’t work. Is there another solution?

    Best
    cityfox

    https://wordpress.org/plugins/relevanssi/

Viewing 1 replies (of 1 total)
  • Plugin Author Mikko Saari

    (@msaari)

    If you want to completely exclude the media files, it’s best to do it in indexing, that way you get a search that performs slightly better.

    add_filter('relevanssi_do_not_index', 'rlv_media_indexing', 10, 2);
    function rlv_media_indexing($block, $post_id) {
        if (has_term(90, 'media_category', $post_id)) $block = true;
        return $block;
    }

    Add this code to the theme functions.php and rebuild the index. Now the media files in the category 90 should be gone.

Viewing 1 replies (of 1 total)

The topic ‘How to exclude certain media categories’ is closed to new replies.