Forums

search-everything : don't search tags of draft posts (4 posts)

  1. mattebb
    Member
    Posted 2 years ago #

    Hi,

    I installed the search everything plugin in order to search through my post tags. The problem, however, is that it also returns search results for draft posts, which I don't want people to see (well it's pointless anyway since when you click on the post title, it says nothing found).

    I made a small modification to search-everything to search tags only in published posts, I hope it's useful for anyone facing the same trouble.

    search_everything.php: line 226

    old:
    $where .= " OR ( tter.slug LIKE '%" . $wpdb->escape($wp_query->query_vars['s']) . "%') ";

    new:
    $where .= " OR (( tter.slug LIKE '%" . $wpdb->escape($wp_query->query_vars['s']) . "%') AND post_status='publish') ";

    cheers

    Matt

  2. searchen
    Member
    Posted 1 year ago #

    Many thanks... this a has plagued me for a while!!
    Peter

  3. daltonrooney
    Member
    Posted 1 year ago #

    Excellent! This can be used to limit metadata searches to published posts as well. Look for line 212, replace

    $where .= " OR (m.meta_value LIKE '%" . $wpdb->escape($wp_query->query_vars['s']) . "%') ";

    with

    $where .= " OR ((m.meta_value LIKE '%" . $wpdb->escape($wp_query->query_vars['s']) . "%') AND post_status='publish') ";

  4. JediSthlm
    Member
    Posted 1 year ago #

    Thanks, both 'mattebb' and 'daltonrooney' tips works great.

Topic Closed

This topic has been closed to new replies.

About this Topic