Post Formats of WordPress

Post Formats 是wordpress 3.1 引入的新更能,直观的,你可以在写文章页面看到

然后再single.php模板文件里可以看到这样一行代码

[code]get_template_part( ‘content’, get_post_format());[/code]

来指定这篇文章使用哪个模板文件。

在/wp-includes/post.php 里面,可以看到系统预设的几个格式。

[code]
5126 function get_post_format_strings() {
5127 $strings = array(
5128 ‘standard’ => _x( ‘Standard’, ‘Post format’ ), // Special case. any value that evals to false will be considered standard
5129 ‘aside’ => _x( ‘Aside’, ‘Post format’ ),
5130 ‘chat’ => _x( ‘Chat’, ‘Post format’ ),
5131 ‘gallery’ => _x( ‘Gallery’, ‘Post format’ ),
5132 ‘link’ => _x( ‘Link’, ‘Post format’ ),
5133 ‘image’ => _x( ‘Image’, ‘Post format’ ),
5134 ‘quote’ => _x( ‘Quote’, ‘Post format’ ),
5135 ‘status’ => _x( ‘Status’, ‘Post format’ ),
5136 ‘video’ => _x( ‘Video’, ‘Post format’ ),
5137 ‘audio’ => _x( ‘Audio’, ‘Post format’ ),
5138 );
5139 return $strings;
5140 }
5141
[/code]

但是仍然需要在模板文件里注册主持。

方法是在模板的 function.php 里加上

add_theme_support( 'post-formats', array( 'aside', 'link', 'gallery', 'status', 'quote', 'image' ) );

或者你觉得不需要这么多,可以删除一些。但是必须和上面预设的单词一样,程序会比较模板注册的和默认的格式,只有匹配的才主持。

感觉有些不太只能,但是想想有7中格式了,也差不多了。

Comments are closed.