1. 主页
  2. 文档
  3. WordPress函数
  4. get_post_type

get_post_type

通过ID获取文章的类型

举例:

1)
if ( 'post' === get_post_type() )
2)
<?php echo get_post_type( $post ) ?>
3)
<?php echo 'The post type is: ' . get_post_type( get_the_ID() ); ?>

参数

$post

(mixed) (可选) Post object or post ID. If empty, the current post will be used.

默认值: null

返回值

(boolean|string)

post type or false on failure.

这篇文章对您有用吗?

我们要如何帮助您?