Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




get_post_type [ WordPress Function ]

get_post_type ( $the_post = false )
Parameters:
  • (mixed) $the_post Optional. Post object or post ID.
Uses:
  • $post
Returns:
  • (bool|string) post type or false on failure.
Defined at:



Retrieve the post type of the current post or of a given post.

Source


<?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;
}
?>

Examples [ wp-snippets.com ]

Top Google Search Results

More ...

0 User Note(s)

None yet. Be the first!

Add New ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics