戴兜的小屋
戴兜的小屋

为Akina-Siren主题添加说说功能

最近更新:原作者评论了,鸡冻 🙂
有一种更方便的办法来建立说说页面,请看>>>传送门

首先感谢keith制作的Akina-Siren主题,非常漂亮 🙂
我仿照http://skyarea.cn/everything/feeling魔改了一个说说页面,非常简单。
这是效果:https://daidr.me/feeling/

修改首页

选择的风格为「标准」:
修改「/wp-content/themes/Akina-Siren/」下的「index.php」文件。
将第56行的

get_template_part( 'tpl/content', get_post_format() );

修改为

if(get_post_format() <> "status") {
	get_template_part( 'tpl/content', get_post_format() );
}

保证「状态」形式的文章不会显示在首页。

选择的风格为「图文」:
修改「/wp-content/themes/Akina-Siren/tpl/」下的「content-thumb.php」文件。
在第11行增加

if (get_post_format() == "status") {
	continue;
}

保证「状态」形式的文章不会显示在首页。

添加模板文件

在「/wp-content/themes/Akina-Siren/」下添加「statuspage.php」文件(随便你咋命名,自己看得懂就可以)
内容如下:

<?php
/*
Template Name: statuspage
*/
get_header();
?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php while(have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php if(akina_option('patternimg') || !get_post_thumbnail_id(get_the_ID())) { ?>
<?php } ?>
<?php
$the_query = new WP_Query( 'posts_per_page=-1&ignore_sticky_posts=1' );
while ( $the_query->have_posts() ) : $the_query->the_post();
if (get_post_format() != "status") {
continue;
}
get_template_part( 'tpl/content', get_post_format() );
endwhile;
wp_reset_postdata();
?>
<?php endwhile; ?>
</main><!-- #main -->
<?php if ( akina_option('pagenav_style') == 'ajax') { ?>
<div id="pagination"><?php next_posts_link(__('Previous')); ?></div>
<?php }else{ ?>
<nav class="navigator">
<?php previous_posts_link('<i class="iconfont">&#xe679;</i>') ?><?php next_posts_link('<i class="iconfont">&#xe6a3;</i>') ?>
</nav>
<?php } ?>
</div><!-- #primary -->
<?php get_footer(); ?>

添加新页面

新建一个页面,选择模板为「statuspage」,页面标题设置为「说说」,页面内容为

<div style="text-align: center; margin-bottom: 45px;">
 <span style="font-family: arial, helvetica, sans-serif; font-size: 25px; font-weight: 400; padding-right: 15px; border-right: 1px dashed #ddd; color: #676767;">说说</span>
 <span style="font-family: arial, helvetica, sans-serif; font-size: 15px; color: #9c9c9c; padding-left: 10px; position: relative; top: -2px;">最狂的风,最静的海。</span>
</div>

后续

希望你还没有根据上面的方法修改你的模板。。

这里有一种更简单的方式来实现说说功能。

1.「后台 – 文章 – 分类目录」,新建一个分类,命名为「说说」,查看这个分类的tag_id。
2.进入「外观 – 主题设置 – 其它 –  首页不显示的分类文章」,输入刚刚得到的tag_id。
3.进入分类的详细设置,「图像描述」的内容即为副标题。
4.然后将所有说说的分类设置为「说说」,即可完成说说页面的搭建。

赞赏

戴兜

文章作者

发表回复

textsms
account_circle
email

  • 哈哈,设置分类文章不显示在首页在主题里是有设置的哈, 主题设置-其它–首页不显示的分类文章(这里填写要隐藏的分类目录的ID就可以了),ID就是在点开文章分类目录设置的时候,浏览器地址里有http://……..category&tag_ID=4, 这个4就是ID

    6 年前 回复
    • DaiDR博主

      @keith: 哇,涨知识了,原来都不知道,绕了那么大弯路 ❗

      6 年前 回复

戴兜的小屋

为Akina-Siren主题添加说说功能
最近更新:原作者评论了,鸡冻 :) 有一种更方便的办法来建立说说页面,请看>>>传送门 首先感谢keith制作的Akina-Siren主题,非常漂亮 :smile: 我仿照http://skyarea.cn/everythi…
扫描二维码继续阅读
2017-11-22