echo user field in loop
-
I’ve created a user field called ‘location’ and added it to my authors.php file using the following shortcode:
<?php echo do_shortcode("[types usermeta='location' user_is_author='true'][/types]"); ?>
Works great!
I also have a page called page-template-authors.php, where I’m listing all my authors, but I can’t figure out how to get the shortcode to work within this page. Obviously, using the current author isn’t an option, because the loop is running through all authors. Instead, I need to tap into the existing loop. I’m using Elegant Theme’s Extra theme. As an example this is the code calling the display name of the author:
<?php foreach ( $authors_page_vars['authors'] as $author ) { ?> <?php echo esc_html( $author->display_name ); ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘echo user field in loop’ is closed to new replies.