Created
May 10, 2013 08:26
-
-
Save vicchi/5553170 to your computer and use it in GitHub Desktop.
Custom page template, based on the stock Twenty Ten theme, to produce a list of each user's WP Biographia Biography Box followed by that user's latest post. Assumes PHP 5.0 and higher.
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 | |
/** | |
* @package WordPress | |
* @subpackage Twenty_Ten | |
* @since Twenty Ten 1.0 | |
* Template Name: Biographies | |
*/ | |
$fields = array(0 => 'ID', 1 => 'user_login'); | |
$args = array('orderby' => 'nicename', 'fields' => $fields); | |
$user_query = new WP_User_Query($args); | |
$users = $user_query->get_results(); | |
get_header(); | |
?> | |
<div id="container"> | |
<div id="content" role="main"> | |
<?php | |
foreach ($users as $user) { | |
$post_args = array('author' => $user->ID, | |
'post_type' => 'post', | |
'posts_per_page' => 1, | |
'post__in' => get_option('sticky_posts'), | |
'ignore_sticky_posts' => 1 | |
); | |
$orig_query = clone $wp_query; | |
$wp_query = new WP_Query($post_args); | |
if (have_posts()) { | |
if (function_exists('wpb_the_biography_box')) { | |
wpb_the_biography_box('raw', $user->user_login); | |
} | |
get_template_part('loop', 'single'); | |
} | |
wp_reset_postdata(); | |
$wp_query = clone $orig_query; | |
} // end-foreach ($users ...) | |
?> | |
</div> | |
</div> | |
<?php | |
get_sidebar(); | |
get_footer(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment