Support » Fixing WordPress » WP_Query in plugin defaults author to current user

  • I am working on a plugin and encountered something strange. I create a new WP_Query and pass some arguments, including “author”=> NULL, but the query returns with [query_vars][author] => 10 (or whatever the ID of the current non-admin user is). Consequentially, the posts returned all belong to the current user.

    Has anyone else ever experienced this?

    add_filter('views_edit-post', array(&$this,'fix_post_counts'));
    
    	public function fix_post_counts($views) {
    	    global $current_user, $posts, $wp_query;
    	    $result = new WP_Query(array(
    	    		"post_status" => NULL,
    	    		"posts_per_page" => -1,
    	    		"author" => NULL,
    	    ));
    	    print_r($result); //Returns with author set
           }

    Unfortunately, this is all running local, so no link just yet.

Viewing 1 replies (of 1 total)
  • esmi

    (@esmi)

    Forum Moderator

    Why specify "author" => NULL? I don’t think you can use null as a value with WP_Query parameters.

Viewing 1 replies (of 1 total)
  • The topic ‘WP_Query in plugin defaults author to current user’ is closed to new replies.