File: /www/wwwroot/www.213n.cn/wp-content/themes/rk-blogger/sidebar.php
<?php
/**
* The template for the sidebar containing the main widget area
*
* Author: wbolt team
* Author URI: https://www.wbolt.com
*/
?>
<div class="sidebar">
<div class="sb-inner sticky-top">
<?php echo wb_insert_ad_block('sidebar', 'mb adbanner'); ?>
<?php if (wb_dynamic_sidebar_switch() && is_active_sidebar('sidebar-def')) :
dynamic_sidebar('sidebar-def');
endif; ?>
<section class="tabs mb" id="J_tabBoxSideBar">
<ul class="tab-nav">
<li class="nav-item current" data-index="0"><a><span>热门文章</span></a></li>
<li class="nav-item" data-index="1"><a><span>随机文章</span></a></li>
<li class="nav-item" data-index="2"><a><span>热门关键词</span></a></li>
</ul>
<div class="tab-conts">
<div class="tab-cont current">
<ul class="post-list rec-ul-bull recul-row-1" id="tab-posts">
<?php
$strdate = date('Y-m-d', strtotime('-1 year', time()));
$q_cat = '';
if (is_category()) {
$q_cat = '&cat=' . $wp_query->get('cat');
} else if (is_single()) {
$term = wp_get_post_terms(get_the_ID(), 'category');
//print_r($term);
if ($term)
$q_cat = '&cat=' . $term[0]->term_id;
if (get_the_ID()) {
$q_cat .= '&exclude[]=' . get_the_ID();
}
} else if (is_search()) {
$q_cat = '';
}
$posts = get_posts("numberposts=10$q_cat&date_query[after]=$strdate&orderby=meta_value_num&meta_key=post_views_count&order=DESC");
$idx = 0;
foreach ($posts as $post) : $idx++; ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach;
$number = 10 - $idx;
if ($number > 0) {
$posts = get_posts("numberposts={$number}$q_cat&date_query[before]=$strdate&orderby=rand&order=DESC");
foreach ($posts as $post) : ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach;
} //end if
?>
</ul>
</div>
<div class="tab-cont">
<ul class="post-list rec-ul-bull recul-row-1" id="tab-posts">
<?php
$posts = get_posts("numberposts=10$q_cat&date_query[after]=$strdate&orderby=rand");
$idx = 0;
foreach ($posts as $post) : $idx++; ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach;
$number = 10 - $idx;
if ($number > 0) {
$posts = get_posts("numberposts=$number$q_cat&date_query[before]=$strdate&orderby=rand");
foreach ($posts as $post) : ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach;
} //end if
?>
</ul>
</div>
<div class="tab-cont cont-tags" id="tab-tags">
<div class="tag-list">
<?php wp_tag_cloud(array(
'largest' => 1,
'smallest' => 1,
'unit' => 'em',
'orderby' => 'count',
'order' => 'DESC',
'number' => 30
)); ?>
</div>
</div>
</div>
</section>
<?php if (wb_get_links()) : ?>
<section class="widget widget-links">
<div class="wp-block-group">
<h2>友情链接</h2>
<div class="links-items">
<?php echo wb_get_links(); ?>
</div>
</div>
</section>
<?php endif; ?>
<?php if (wb_dynamic_sidebar_switch() && is_active_sidebar('sidebar-bottom')) :
dynamic_sidebar('sidebar-bottom');
endif; ?>
<?php echo wb_insert_ad_block('sidebar_b', 'adbanner'); ?>
</div>
</div>