• Resolved jonwatson87

    (@jonwatson87)


    I have a list of authors stored in a variable and want to do a WP_Query based on those values, but can’t quite figure out how to do it.

    So, say my variable echoes back with user-logins: joe.bloggs,jane.doe,steamy.bacon – how do I go about adding posts by those coauthors to my query args?

    https://ww.wp.xz.cn/plugins/co-authors-plus/

Viewing 1 replies (of 1 total)
  • Thread Starter jonwatson87

    (@jonwatson87)

    Got it! 🙂

    I edited my variable ($theauthors) to include the prefix (cap-) so that my variable echoed something like this:

    cap-joe.bloggs,cap-jane.doe,cap-steamy-bacon

    and then used the following tax_query:

    'tax_query' => array(
    	array(
    		'taxonomy' => 'author',
    		'field' => 'slug',
    		'terms' => explode(',', $theauthors)
    	)
    )
Viewing 1 replies (of 1 total)

The topic ‘Querying Multiple Authors in WP_Query’ is closed to new replies.