Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php /*
- Template Name: Authors
- */ ?>
- <?php get_header(); ?>
- <div id="container">
- <div id="content">
- <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
- <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
- <h2 class="entry-title"><?php the_title(); ?></h2>
- <div class="entry-content">
- <?php the_content(); ?>
- <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
- <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="edit-link">', '</span>' ); ?>
- </div><!-- .entry-content -->
- </div><!-- #post-## -->
- <?php endwhile; // end of the loop. ?>
- <?php
- // Show a selected number of posts per row
- $posts_per_row = 5;
- if (have_posts()) {
- global $wpdb;
- $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users WHERE display_name <> 'admin' ORDER BY display_name");
- //these are the arguments for the get_users function below
- $args = array(
- 'fields' => 'all_with_meta',
- 'meta_query' => array(
- array(
- 'key' => 'twitter', // the meta field (or key) we want to target
- 'value' => 'Ihavenotweets', // the value we want to target (optional)
- 'compare' => '>=' // comparison method (optional: =, >, <, etc)
- )
- ));
- //get_users calls WP_User_Query and returns an array of matching users
- $users = get_users($args);
- //custom function for comparing the data we want to sort by
- function cmp($a, $b){
- if ($a->points == $b->points) {
- return 0;
- }
- return ($a->points > $b->points) ? -1 : 1;
- }
- //usort sorts our $users array with our function cmp()
- usort($users, 'cmp');
- //leaving an array of $users sorted by the value of meta 'points'
- foreach ($users as $author ) :
- // Get user data
- $curauth = get_userdata($author->ID);
- $curauth->user_email;
- // Get link to author page
- $user_link = get_author_posts_url($curauth->ID);
- //show authors with posts
- $post_count = get_usernumposts($curauth->ID);
- if (!$post_count) {
- } else
- while (have_posts()) {
- the_post();
- if ((++$post_counter % $posts_per_row) == 1 || $posts_per_row == 1) {
- if ($post_counter > 1) {
- echo
- "</div><!-- End of post_row -->\n"; // End previous row
- }
- echo "<div class='post_row3'>\n"; // Start a new row
- }
- echo "<div
- class='post_class3'>\n"; // Start one post
- // Output post data here
- ?>
- <div class="entry-meta">
- <a href="<?php echo $user_link; ?>" title="<?php echo $curauth->display_name; ?>"><?php echo $curauth->display_name; ?></a>
- </div>
- <a href="<?php echo $user_link; ?>" title="<?php echo $curauth->display_name; ?>">
- <?php echo get_avatar($curauth->user_email, '96', $avatar); ?></a>
- <?php //endwhile
- echo "</div><!-- End of post_class -->\n"; // End of post
- } ?>
- <?php endforeach; ?>
- <?php //endif
- } ?>
- </div><!-- End of post_row -->
- </div>
- </div><!-- #container -->
- <?php get_sidebar();?>
- <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement