WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] posts_where filters (2 posts)

  1. openwp3
    Member
    Posted 1 year ago #

    Can anyone give me a tip on how to correctly add additional statuses to this statement (i.e. 'trash', 'draft', etc.):

    function search_site_where ($where = '') {
    
    	global $wpdb;
    
    	return $where .= " AND {$wpdb->posts}.post_status != 'private' ";
    }

    I'm adding to a pre_get_posts $query.

    I've tried setting a variable with array and for each statement, neither seems to work.

    Any ideas?

  2. openwp3
    Member
    Posted 1 year ago #

    Firgured out on my own:

    return $where .= " AND {$wpdb->posts}.post_status != 'private' AND {$wpdb->posts}.post_status != 'trash' ";

    Hope it helps someone else.

Topic Closed

This topic has been closed to new replies.

About this Topic