-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinc_shortcodes.php
More file actions
75 lines (64 loc) · 1.85 KB
/
inc_shortcodes.php
File metadata and controls
75 lines (64 loc) · 1.85 KB
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
<?php
function adm_sitemap($atts, $content = null, $code) {
if(isset($atts['type'])){
switch($atts['type']){
case 'page': case 'pages':
return adm_sitemap_pages($atts);
case 'post': default:
return adm_sitemap_posts($atts);
}
}
return '';
}
add_shortcode('sitemap', 'adm_sitemap');
///////////////////////////////////////////////////////////////////////////////
function adm_sitemap_pages($atts){
extract(shortcode_atts(array(
'number' => '0',
'depth' => '0',
'exclude' => ''
), $atts));
return '<div class="sc-sitemap sitemap-pages"><ul>'.wp_list_pages('depth=0&sort_column=menu_order&echo=0&title_li=&depth='.$depth.'&number='.$number.'&exclude='.$exclude ).'</ul></div>';
}
///////////////////////////////////////////////////////////////////////////////
function adm_sitemap_posts($atts){
extract(shortcode_atts(array(
'comments_number' => true,
'number' => '0',
'cat' => '',
'posts' => '',
'author' => '',
'type' => 'post',
'comments' => 'true'
), $atts));
if($number == 0){
$number = 1000;
}
if($comments_number === 'false'){
$comments_number = false;
}
$query = array(
'showposts' => (int)$number,
'post_type'=>$type//'post',
);
if($cat){
$query['cat'] = $cat;
}
if($posts){
$query['post__in'] = explode(',',$posts);
}
if($author){
$query['author'] = $author;
}
$archive_query = new WP_Query( $query );
$output = '';
while ($archive_query->have_posts()) : $archive_query->the_post();
$output .= '<li><a href="'.get_permalink().'" rel="bookmark" title="'.sprintf( __("Permanent Link to %s", 'striking_front'), get_the_title() ).'">'. get_the_title().'</a>';
if( $comments == 'true' ) {
$output .= ($comments_number?' ('.get_comments_number().')':'');
}
$output .= '</li>';
endwhile;
wp_reset_query();
return '<div class="sc-sitemap sitemap-posts"><ul>'.$output.'</ul></div>';
}