WordPress 101 主题学习教程: 07 – 创建并加入文章格式(展示类型)

WordPress 101 – Part 7: How to add and create Post Formats

视频学习参考: https://www.youtube.com/watch?v=ut5b0gSpV1w&list=PLriKzYyLb28nUFbe0Y9d-19uVkOnhYxFE&index=7

1.启用文章类型功能支持, 打开functions.php

//一共有9种支持的文章类型 从4.1.2版本开始

add_theme_support(‘post-formats’, array(‘aside’, ‘image’, ‘video’));

2.通过 get_post_format() 返回 当前文章的格式

3.在index.php的post循环中 加入

<?php get_template_part(‘content’, get_post_format()); ?> //会自动寻找content-xxx.php作为底板,如果content-xxx.php不存在则用content.php

取代原来的内容展示 并将内容展示移入 content.php中

4.创建不同的content-xxx.php

Super Simple!

P.S. aside是日志的意思