-
-
Save fritids/5225774 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Template Name: All Authors' Page | |
Description: Get all the WordPress user's meta_information sort by the latest post action. (Which had at least 1 post published.) | |
*/ | |
?> | |
<?php get_header(); ?> | |
<ul> | |
<?php | |
// offset -> post number | -1 means all the posts. | |
function get_latest_post_authors($number = 10,$offset = -1){ | |
global $post; | |
$args = array( 'numberposts' => $offset); | |
$authors_id = array(); | |
$myposts = get_posts( $args ); | |
foreach( $myposts as $key => $post ){ | |
setup_postdata($post); | |
if(count($authors_id) >= $number) break; | |
if(!in_array($post->post_author, $authors_id)){ | |
array_push($authors_id,$post->post_author); | |
} | |
} | |
return $authors_id; | |
} | |
foreach( get_latest_post_authors() as $key => $author_id): | |
$author_meta = get_user_meta($author_id); | |
// get what you need. | |
// var_dump($author_meta); | |
?> | |
<li>Nickname: <?php echo $author_meta['nickname'][0];?></li> | |
<?php | |
endforeach; | |
?> | |
</ul> | |
<?php get_sidebar(); ?> | |
<?php get_footer(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment