說明
檢索當前文章或給定文章的文章類型。
用法
- <?php?get_post_type(?$post?)??>
參數
$post
(混合)(可選)文章對象或文章ID。
默認值: false
返回的值
(布爾型| 字符)
返回文章類型,出錯時返回false。
示例
- <?php
- $post_type?=get_post_type(36);
- echo?$post_type;
- ?>
注釋
用法:$posts 日志循環的全局變量
修改記錄
自2.1.0版本后
源文件
get_post_type() 位于wp-includes/post.php中
-
-
-
-
-
-
-
-
-
-
- function get_post_type( $the_post = false ) {
- global $post;
-
- if ( false === $the_post )
- $the_post = $post;
- elseif ( is_numeric($the_post) )
- $the_post = get_post($the_post);
-
- if ( is_object($the_post) )
- return $the_post->post_type;
-
- return false;
- }