首页 > WordPress > WordPress 文章形式post-format几种使用方式

WordPress 文章形式post-format几种使用方式

时间:2022年6月15日 分类:WordPress 浏览量:355

在WordPress中,文章形式有很多种,一般采用默认的,不需要配置,而其他形式,则需要通过post-format来添加。

post format(文章格式)是wordpress 3.1引入的一个新的特征。主题可以根据post format以不同的方式来展示文章。

wordpress提供了一些标准的post format,作为wordpress主题的开发者不必去支持每一种post format,当然也可不支持任何一种。post format的类型不能通过主题或者插件进行添加。

简单的说,如果一个wordpress主题支持post format,当文章发布时可以选择post format类型来以不同的方式来展示这篇文章。

如果想让主题支持post format,只需将add_theme_support()函数添加在functions.php中即可,如:

add_theme_support( 'post-formats', array( 'aside', 'gallery');
aside 日志
chat 聊天
gallery 相册
link 链接
image 图像
quote 引语
status 状态
video 视频
audio 音频

上面代码默认只是添加了post类文章可选post format。如果想让页面(Page)或者自定义post类型支持post format,需要使用add_post_type_support()函数,同样将其放在functions.php中。如:

// add post-formats to post_type 'page'
add_post_type_support( 'page', 'post-formats' );
 
// add post-formats to post_type 'my_custom_post_type'
add_post_type_support( 'my_custom_post_type', 'post-formats' );

get_post_format()函数位于:wp-includes/post-formats.php

相关函数:

  • set_post_format()
  • has_post_format()
  • get_post_format_link()
  • get_post_format_string()
  • the_post_format_audio()
  • get_the_post_format_media()
  • get_content_audio()
  • the_post_format_chat()
  • get_the_post_format_chat()
  • get_content_chat()
  • add_chat_detection_format()
  • the_post_format_gallery()
  • get_content_galleries()
  • get_post_gallery_images()
  • the_post_format_image()
  • get_the_post_format_image()
  • get_content_images()
  • the_post_format_quote()
  • get_the_post_format_quote()
  • get_content_quote()
  • the_post_format_url()
  • get_the_post_format_url()
  • get_content_url()
  • the_post_format_video()
  • get_content_video()
  • the_remaining_content()
  • get_the_remaining_content()
  • get_post_format_meta()
  • post_format_content_class()
  • get_post_format_content_class()
  • post_formats_compat()

觉得文章有用就打赏一下文章作者

微信扫一扫打赏

标签: