• Resolved Brun?o

    (@brunosousa)


    Hello,

    I have a loop in which shows up a list of users. I tried your previews suggestions in other topics for retrieving the terms, but had no success.

    My loop:

    <?php
    
    	 // WP_User_Query arguments
    	args = array (
    	role' => 'especialista',
    	);
    							  
    	// Create the WP_User_Query object
    	$wp_user_query = new WP_User_Query($args);
    							  
    	/ Get the results
    	$authors = $wp_user_query->get_results();
    							  
    	// Check for results
    	if (!empty($authors)) {
    	     // loop through each author
    	     foreach ($authors as $author){  ?>
                                      
                     <li>
                         <div class="my_user">
                              <h1><a href="<?php echo get_author_posts_url( $autho->ID, $author->user_nicename ); ?>"><?php echo $author->user_nicename; ?></a></h1>
                         </div>
    
                         <div class="user_terms">
                              <div class="col-xs-12">                             
                              
                              //list my terms from multiple taxonomies, like array('tax_1', 'tax_2', 'tax_3');                                       
                              </div>
                          </div>
                                                                                               	
                    </li><!--col-xs-12-->    
                    <?php }
    								   
    	} else {
    	echo 'Nada Encontrado';
    	}
    	?>

    Could you help me in how to get these terms from User taxonomies?

    Thanks in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • James Maiden

    (@reallygreenjames)

    Out of interest Bruno, did you ever figure this out? I would like to know the same.

    Plugin Author shawfactor

    (@shawfactor)

    Guys,

    this should work, any issues please let me know:

    $term = get_term_by(‘slug’, ‘taxonomy_name’, $taxonomy->name);
    $user_ids = get_objects_in_term($term->term_id, $taxonomy->name);

    $args = array(
    ‘include’ => $user_ids
    );

    $query = new WP_User_Query( $args );

    Plugin Author shawfactor

    (@shawfactor)

    hopefully this answers you satisfactorily, I am resolving this for good order

    • This reply was modified 7 years, 11 months ago by shawfactor.
    James Maiden

    (@reallygreenjames)

    Great. Thanks.

    Keep up the good work ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘List terms from User and “archive.php” for Users’ is closed to new replies.