Forums

new WP_Query and WHERE (5 posts)

  1. lolalola
    Member
    Posted 1 year ago #

    Hi,
    why ignore my second WHERE function?
    With this function I get all news but with all users.
    Why grab and users where id is 1?

    $news = new WP_Query('post_type=news&post_author!=1&orderby=ID&order=ASC');

    Thanks ;)

  2. jkovis
    Member
    Posted 1 year ago #

    To exclude posts from an author with an id of 1 use:

    $news = new WP_Query('post_type=news&post_author=-1&orderby=ID&order=ASC');
  3. lolalola
    Member
    Posted 1 year ago #

    Thanks for help,
    but this no work...It's the same, i get with all authors.

  4. alchymyth
    The Sweeper
    Posted 1 year ago #

    Exclude Posts Belonging to an Author

    Display all posts except those from an author by prefixing its id with a '-' (minus) sign:

    $query = new WP_Query( 'author=-12,-34,-56' );

    http://codex.wordpress.org/Function_Reference/WP_Query#Author_Parameters

  5. jkovis
    Member
    Posted 1 year ago #

    whoops author !== post_author, good catch alchymyth

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags