Filter post by current 2 differents users id
I'm filtering my custom post type based on author. I want all users to be able to: 1 - in the list everyone can see the posts created by the admin. 2 - users can also see their own posts in the list, but not those of other users.
I can list by admin id only or current user id only, but not both. Code:
function list_cpt_by_author_id(){
$user = new WP_User(get_current_user_id());
$authors_id = array(
array('author' = 1),
array('author' = $user),
);
$custom_terms = get_terms('custom-tax');
foreach($custom_terms as $custom_term) {
wp_reset_query();
$args = array(
'post_type' = 'artigos',
'tax_query' = array(array('taxonomy' = 'custom-tax','field' = 'slug','terms' = $custom_term-slug,),),
$authors_id,);
$loop = new WP_Query($args);
$image = get_field( 'cat_imagem', $custom_term );
//Taxonomies Loop
if($loop-have_posts()) {
echo 'h2'.$custom_term-name.'/h2';
echo 'img src='.$image.'/';
//Post loop
while($loop-have_posts()) : $loop-the_post();
echo 'a href='.get_permalink().''.get_the_title().'/abr';
endwhile;
}
wp_reset_postdata(); // reset global $post;
}
}
Can anyone give me any tips?
UPDATE
Thanks to @ali Sh help I did: 'author' = $adm_u_id .',' . $u_id_c
$adm_u_id
so I can list any future editor ids and $u_id_c
to list the userid of the current user.
Topic plugin-list-category-post author loop custom-post-types Wordpress
Category Web