27 Apr 2017

Get entry type. Is it a post or a page?

Here's a handy little snippet that determines if an entry is a post or page within a loop. I found this usefull for determining the entry type within search results, where I wanted to style the results differently depending on what type of result it was.

$pagetype = get_post_type( $post_id );

echo $pagetype;

if ($pagetype == "post") {
// do something