这款主题好像排名还挺靠前,安装后首页各个模块内容都是重复的,比如滑动图文那里,跟右侧tab区块和顶部最新文章、右侧边栏最新文章都是一个内容。将滑动图文改为调取特殊标签文章,实现重点推荐。
1、创建一个特殊TAG,比如“推荐”,这个tag_id可以在后台右键看到,比如是12。
2、修改themes/newsup/inc/ansar下的template-functions.php文件,利用87行newsup_get_posts函数构建一个newsup_get_tag,内容如下:
//自定义调取TAG文章
if (!function_exists('newsup_get_tag')):
function newsup_get_tag($number_of_posts, $tag = '12')
{
$ins_args = array(
'post_type' => 'post',
'posts_per_page' => absint($number_of_posts),
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC',
'tag_id' => '12',
'ignore_sticky_posts' => true
);
$tag = isset($tag) ? $tag : '12';
if (absint($tag) > 0) {
$ins_args['tag_id'] = absint($tag);
}
$all_posts = new WP_Query($ins_args);
return $all_posts;
}
endif;
添加在newsup_get_posts后面,保存。
3、修改themes/newsup/inc/ansar/hook/blocks/里的block-banner-list.php文件,将第4行原来调取最新文章的代码更改为调取“推荐”标签文章:
$newsup_all_posts_main = newsup_get_tag($newsup_number_of_slides, $newsup_slider_category);
刷新首页,滑动图文就会显示你打上推荐标签的文章了,实现精准上首。