1、在后台管理-文章-所有文章下,选择你要置顶的文章,点击快速编辑,选置顶文章然后更新;


2、在dux主题文件夹下打开index.php,找到如下代码:
1 2 3 4 |
$args = array( 'ignore_sticky_posts' => 1, 'paged' => $paged ); |
将 ‘ignore_sticky_posts’ => 1, 中的 1 改为0;
1 2 3 4 |
$args = array( 'ignore_sticky_posts' => 0, 'paged' => $paged ); |
3、在excerpt.php中找到如下代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
echo '<header>'; if ($p_meta && $p_meta['cat'] && !is_category()) { $category = get_the_category(); if ($category[0]) { echo '<a class="cat" href="'.get_category_link($category[0] - >term_id).'">'.$category[0] - >cat_name.'<i></i></a> '; } }; echo '<h2><a'._post_target_blank().' href="'.get_permalink().'" title="'.get_the_title().get_the_subtitle(false)._get_delimiter().get_bloginfo('name').'">'.get_the_title().get_the_subtitle().'</a></h2>'; if (is_sticky()) { echo '<span class="zd">置顶</span>'; } echo '</header>'; |
将 if (is_sticky()) {echo ‘<span class=”zd”>置顶</span>’;} 插入至上面代码;
4、修改main.css文件,在文件中追加:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
.excerpt { position: relative; } .excerpt .zd { position: absolute; right: -38px; top: -16px; display: block; width: 76px; height: 20px; line-height: 20px; background: #ff5e52; color: #fff; font-size: 14px; font-weight: 400; text-align: center; transform: rotate(45deg); transform-origin: 0% 0%; } |
大功告成!效果图见本站首页。