-
Notifications
You must be signed in to change notification settings - Fork 0
/
list-by-author.php
56 lines (45 loc) · 948 Bytes
/
list-by-author.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
<?php
/*
Template Name: seznam po avtorju
*/
wp_head();
global $wp_query, $wpdb, $post;
$myauthor = $_GET['a'];
$args = array(
'status' => 'publish',
'posts_per_page' => -1,
'post_type' => 'post',
'tax_query' => array(
array(
'taxonomy' => 'ime_avtorja',
'field' => 'slug',
'terms' => $myauthor
),
),
'orderby' => 'date',
'order' => 'DESC'
);
$authorsposts = new WP_Query($args);
$myurls = array();
if ($authorsposts->have_posts()) :
echo "<pre>";
while ($authorsposts->have_posts()) : $authorsposts->the_post();
$_mycategories = get_the_category();
$mycategories = array();
foreach ($_mycategories as $mycat) :
$mycategories[] = $mycat->name;
endforeach;
$mystring = get_the_title()
. " "
. join('/', $mycategories)
. " "
. get_the_date('Y')
. " "
. get_the_permalink();
echo $mystring . "\n";
endwhile;
echo "</pre>";
else :
echo "<p>No posts to show</p>";
endif;
?>