因为RiPro主题添加了视频、音频、素材功能,在相关推荐上就会出现推荐不同的文章,推荐就会出现不同的缩略图,感觉起来并不美好。
找到parts/related-posts.php文件1-25行即下面代码:
<?php
$type = 'tag';
$terms = get_the_tags();
if (!$terms) {
$terms = get_the_category();
$type = 'category';
}
if ( $terms && _cao( 'disable_related_posts') == 1 ) :
$args = array(
'orderby' => 'rand',
'post__not_in' => array( get_the_ID() ),
'posts_per_page' => _cao('related_posts_num','4'),
);
$term_ids = array();
foreach ( $terms as $term ) {
$term_ids[] = $term->term_id;
}
switch ( $type ) {
case 'tag' :
$args['tag__in'] = $term_ids;
break;
case 'category' :
$args['category__in'] = $term_ids;
break;
}
替换为:
<?php
$type = 'tag';
$terms = get_the_tags();
if (!$terms) {
$terms = get_the_category();
$type = 'category';
}
if ( $terms && _cao( 'disable_related_posts') == 1 ) :
$args = array(
'orderby' => 'rand',
'post__not_in' => array( get_the_ID() ),
'posts_per_page' => _cao('related_posts_num','4'),
);
$term_ids = array();
foreach ( $terms as $term ) {
$term_ids[] = $term->term_id;
}
switch ( $type ) {
case 'tag' :
$args['tag__in'] = $term_ids;
break;
case 'category' :
$args['category__in'] = $term_ids;
break;
}