I am trying to find out the post type from a category id.
Suppose that, when i am opening a category page
localhost/project/foobaar/category/pen
I want to know the post type to which category - pen is attached to. I have two custom post type named "book" and "copy" If category pen is associated with book, then it should return the post type as "book" Similarly if category is pencil, then it should return "copy" as i have used pencil category in "copy" post.
I was trying to do something like this as (i have the category id stored in variable but assume category id of pen is 12)
$args = array (
posts_per_page => 1,
category => '12' // category id of pen
);
$posts = WP_Query( $args );
And from $posts I could get one post from which I could knew, but $args is using default post_type as 'posts' and my posts can be anything.
Thanks