WordPressでpost_typeを取得する場合 通常 get_post_type() を使うのですが、投稿が無い時(0件の時) get_post_type() は false を返すため今のページのpost_typeを取得できない場合があります。(カスタム投稿タイプを作って投稿が0件のアーカイブページとか) Source File: wp-includes/post.php <?php function get_post_type( $post = null ) { if ( $post = get_post( $post ) ) return $post->post_type; return false; } 引用元: get_post_type() | Function | WordPress Developer Resources これは投稿がないとglobal $postがN
![WordPress 投稿が0件でもpost_typeを取得したい。 - かもメモ](https://cdn-ak-scissors.b.st-hatena.com/image/square/43b830af1df1cc710a1698c825c5f3bb3e4fb76d/height=288;version=1;width=512/https%3A%2F%2Fimages-fe.ssl-images-amazon.com%2Fimages%2FI%2F61WqKglCHRL._SL160_.jpg)