[wp-trac] [WordPress Trac] #20647: get_post_type() returns nothing on custom post type archive pages with custom query and no results
WordPress Trac
wp-trac at lists.automattic.com
Wed May 9 22:32:23 UTC 2012
#20647: get_post_type() returns nothing on custom post type archive pages with
custom query and no results
-----------------------------+------------------------------
Reporter: MikevHoenselaar | Owner: MikevHoenselaar
Type: defect (bug) | Status: closed
Priority: normal | Milestone:
Component: Post Types | Version: 3.3.2
Severity: normal | Resolution: invalid
Keywords: needs-patch |
-----------------------------+------------------------------
Comment (by MikevHoenselaar):
I expected that get_post_type() would give me the post_type of the query I
did. It's post only. If the main_query on the archive page isn't returning
anything get_post_type() isn't useful now. But it can be useful to get a
post_type.
So you are saying that Yoast will have to edit his plugin and use a
!empty($post_type) after using get_post_type()?
I know that you can have your own if, then, elses in your plugin. And
probably Yoast shouldn't take for granted that there always is a
$post_type returned from get_post_type().
But I believe get_post_type can be better :-).
Adding this will make sure that I always will get a post_type if there is
one.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/20647#comment:4>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list