WordPress获取文章形式函数:get_post_format
文 / @UTHEME
WordPress函数get_post_format用于获取文章的形式,在为不同形式的文章制作不同的模板时非常有用。
get_post_format( int $post = null )
函数参数
$post_id
整数型,默认值:null
文章的ID
函数返回值
- aside 日志
- chat 聊天
- gallery 相册
- link 链接
- image 图像
- quote 引语
- status 状态
- video 视频
- audio 音频
标准形式的文章不会返回任何值。
函数使用示例
$format = get_post_format(); get_template_part( 'format', $format );
扩展阅读
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()

相关文章
-
php 如何禁用notice错误报告(附:WordPress如何禁用notice错误报告) 2023-03-31 13:48:46
-
如何集成element-ui到wordpress后台 2023-03-31 10:04:13
-
WordPress本地化Avatars头像插件:Simple Local Avatars(附:WordPress代码实现本地化Avatars) 2023-03-30 11:23:57
-
sitemap的changefreq详解(附:跨境电商WordPress站的changefreq一般如何设置) 2023-03-27 17:59:27
-
详解sitemap.xml的priority(附:WordPress的priority设置意见) 2023-03-27 17:47:32
-
wordpress 刷新rewrite 规则 2023-03-24 15:07:29
-
如何在WordPress中进行URL重写(rewrite) 2023-03-24 14:57:14
-
如何用代码实现 JWT Authentication for WP REST API 的功能 2023-03-24 14:39:28
-
wordpress 如何实现纯静态缓存 2023-03-23 18:09:16
-
UTHEME工具箱 2023-03-23 10:40:12