[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:19:46 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 scribu):

 wp_reset_postdata() does exactly what you want: restores the $post global
 from the main query. Works for `new WP_Query()` too.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/20647#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list