wordpress get post type

Step 1: Open your WordPress theme's functions.php file.

Step 2: Use the function get_post_type() to retrieve the post type of the current post.

$current_post_type = get_post_type();

Step 3: Optionally, you can specify a post ID to get the post type of a specific post.

$post_id = 123; // Replace 123 with the desired post ID
$post_type = get_post_type($post_id);

Step 4: If you want to display the post type, you can use the following code:

echo 'The post type is: ' . $current_post_type;

Or, for a specific post:

echo 'The post type is: ' . $post_type;

That's it! You've successfully retrieved and displayed the post type in WordPress using the get_post_type() function.