I want to get posts from a particular category or if the post by a particular user . It seems we could only have AND condition in wordpress . I know the below code is wrong but this is what I need to get – I want all the posts written by a particular user OR all the posts from a particular category
$args = array(
'posts_per_page' => 10,
'offset' => $PageStart,
'query' => array(
'relation' => 'OR', /* <-- here */
array(
'author' => 18,
),
array(
'category' => 20,
)
),
'orderby' => 'date',
'order' => 'DESC',
'post_type' => 'post',
'post_status' => 'publish',
);
//print_r($args);
$author_post = get_posts( $args );
Please do help. Thanks in advance .
Try this code
If you want both do
get_posts()
2 times.and then merge both arrays with
array_merge()
I have found solution to this ,I have done it with a custom query
where $cat_list is an array with your category ids and $authors is an array with your author ids . Hope this would help someone in need.