Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $current_user = wp_get_current_user();
- $current_user_posts = get_posts(array(
- 'author' => $current_user->ID,
- 'posts_per_page' => -1
- );
- $current_user_terms = array();
- foreach ($current_user_posts as $user_post) {
- $user_terms = wp_get_post_terms($user_post->ID, 'custom_tax', array("fields" => "ids"));
- foreach ($user_terms as $user_term ) {
- if (!in_array($user_term->term_id, $current_user_terms))
- $current_user_terms[] = $user_term->term_id;
- }
- }
- $your_query = new WP_Query( array(
- 'tax_query' => array(
- array(
- 'taxonomy' => 'custom_tax',
- 'field' => 'term_id',
- 'terms' => $current_user_terms,
- ),
- ));
- if ( $the_query->have_posts() ) { ..
Add Comment
Please, Sign In to add comment