Need help with network_query_posts.

Would just like some assistance with network_query_posts. I'm trying to limit it by excluding certain roles or authors but can't get the syntax right. So this works 'author' => -82, but if I want to exclude multiple authors this is not working 'author__not_in' => array(82) or 'author' => '-2, -3, -4', //excludes users with id 2, 3 and 4.

Please help.

  • Ash
    • WordPress Hacker

    Hello John Wang

    I am afraid, author__not_in is not an option parameter for network_query_posts(). We have sent this issue to our second level support team. Please note that, they deal with more complex issues, so there might be little delay. We appreciate your patience on this.

    Have a nice day!

    Cheers,
    Ash

  • Nithin
    • Support Wizard

    Hi John Wang,

    I'm afraid, this is a bit complex, and was hence raised to our Second Level Support(SLS) team to be looked upon. I'm pinging our SLS team to check the status regrading this query, and will keep you updated via the support ticket once we get a feedback asap.

    We truly appreciate your patience regarding this.

    Regards,
    Nithin

  • Panos
    • SLS

    Hi there John Wang !

    Apologies for delay here.

    Could you please replace file:
    post-indexer/classes/networkquery.php
    with the file attached here?

    I would strogly recommend to first test it out in a local or staging site.

    Then test some queries containing some of the following args for your :
    'author' => '1,2,-3'
    'author__not_in' => array( 1,3 )
    and
    'author__in' => array( 1, 3 )

    eg:

    $args = array(
    		'author__in' => array( 1, 3 ),
    	);
    
    	$network_posts = network_query_posts( $args );

    Please let us know if you still have any issues there. If not, we will shortly do new release with those included.

    Kind regards!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.