-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp_shortcode_pagination.php
43 lines (42 loc) · 1.48 KB
/
wp_shortcode_pagination.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
function pagination($projects) {
extract(shortcode_atts(array(
'pages' => 'pages',
'type' => 'type',
'actual'=> 'actual'
), $projects));
$flag_ret=0;
$all_pages = explode(",", $pages);
if (count($all_pages)>1) {
$flag_ret=1;
$cnt=1;
$ret="<font color='#000'>Páginas:</font> ";
foreach ($all_pages as $page) {
if ($cnt<count($all_pages)) {
$comma="<font color='#000'>,</font> ";
} else {
$comma="";
}
if ($cnt==$actual) {
$bold_cnt="<b>".$cnt."</b>";
} else {
$bold_cnt=$cnt;
}
$ret.="<a href='".$page."'>".$bold_cnt."</a> ".$comma;
$cnt++;
}
}
if (count($all_pages)==1) {
$flag_ret=1;
if ($type=='next') {
$text="Próximo";
}
if ($type=='previous') {
$text="Anterior";
}
$ret="<a href='".$pages."'>".$text."</a>";
}
if ($flag_ret==1) {
return $ret;
}
}
add_shortcode('pagination', 'pagination');