0

I want to get post type of currently visited category or term. As for example, I have post_type post and category named Blog.

On Blog listing page, how can I get that this is a category of the post_type Post?

2
0

Both category and term are taxonomy. Taxonomy doesn't have post type. Post type is related to posts/pages/attachments/etc.

When you assign a category to a post, you can't say that that category has or related to specific post type.

If you want to receive post type of the first entity in the query, you will have to do something like this:

<?php

// fetch first post from the loop
the_post();

// get post type
$post_type = get_post_type(); 

// rewind the loop posts
rewind_posts();

?>
2
  • Thanks for reply, Yes you are right but the case is that i want to get post type. Aug 20 '13 at 9:06
  • @ShaikhAezaz I have updated my answer, maybe it will help you now. Aug 20 '13 at 12:27
0

We can use this like

Reference : http://codex.wordpress.org/Function_Reference/get_post_type

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.