-
Notifications
You must be signed in to change notification settings - Fork 0
/
authors.php
98 lines (65 loc) · 2.19 KB
/
authors.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
/**
* Template Name: Authors List
*/
get_header();
?>
<div class="main wrap cf">
<div class="row">
<div class="col-8 main-content">
<?php if (have_posts()): the_post(); endif; // load the page ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if (Bunyad::posts()->meta('page_title') == 'yes'): ?>
<header class="post-header">
<h1 class="main-heading">
<?php the_title(); ?>
</h1>
</header><!-- .post-header -->
<?php endif; ?>
<div class="post-content">
<?php Bunyad::posts()->the_content(); ?>
</div>
<div class="authors-list">
<?php
$per_page = 10;
$paged = get_query_var('paged');
// setup user query
$user_query = new WP_User_Query(array(
'orderby' => 'post_count',
'order' => 'DESC',
'who' => 'authors',
'offset' => $paged ? (($paged - 1) * $per_page) : 0,
'number' => $per_page,
'count_total' => true,
));
// how many pages?
$total_users = $user_query->get_total();
$pages = $total_users / $per_page;
// get authors
$authors = (array) $user_query->get_results();
foreach ($authors as $author) {
$post_count = count_user_posts($author->ID);
if ($post_count > 0) {
$author->description .= '<span class="posts"><a href="'. get_author_posts_url($author->ID) .'" class="button smaller" title="'. esc_attr(__('Browse Author Articles', 'bunyad')) .'">'
. sprintf(__('%s Articles', 'bunyad'), '<strong>'. $post_count .'</strong>') . '</a></span>';
}
$authordata = $author;
get_template_part('partial-author');
echo '<hr class="separator" />';
}
?>
</div>
</article>
<?php
if ($pages > 1):
$query = (object) array('max_num_pages' => $pages);
?>
<div class="main-pagination">
<?php echo Bunyad::posts()->paginate(array(), $query); ?>
</div>
<?php endif; ?>
</div>
<?php Bunyad::core()->theme_sidebar(); ?>
</div> <!-- .row -->
</div> <!-- .main -->
<?php get_footer(); ?>