get_post_type 获取文章类型WordPress函数
我们在开发在 WordPress 主题中,get_post_type 用来获取文章的类型。如果参数为空,则返回全局 $post 的文章类型。
如果参数为 int 及文章 ID 或 WP_Post 及文章,则返回传入文章的类型。
也想出现在这里?联系我们吧

if ('book' == get_post_type()) {
echo '当前文章类型book';
}
我们在开发在 WordPress 主题中,get_post_type 用来获取文章的类型。如果参数为空,则返回全局 $post 的文章类型。
如果参数为 int 及文章 ID 或 WP_Post 及文章,则返回传入文章的类型。
if ('book' == get_post_type()) {
echo '当前文章类型book';
}