[wp-trac] [WordPress Trac] #27015: WP_Query::get_queried_object() does not always work in 'pre_get_posts'

WordPress Trac noreply at wordpress.org
Sat Jul 29 20:11:40 UTC 2017


#27015: WP_Query::get_queried_object() does not always work in 'pre_get_posts'
-------------------------------------------------+-------------------------
 Reporter:  bcworkz                              |       Owner:
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  Future
Component:  Query                                |  Release
 Severity:  normal                               |     Version:  3.8
 Keywords:  has-patch needs-unit-tests needs-    |  Resolution:
  refresh                                        |     Focuses:
-------------------------------------------------+-------------------------

Comment (by motherofdragons):

 after active woocommerce 3.1.1,on static page wiht get_header() and
 get_footer(),the page got the same error.
 all the solutions didn't work.
 so I add below code in \wp-includes\class-wp-query.php
 just after: {{{#!php
 <?php
 $page_obj = $this->get_queried_object();
 }}}

 my code:

 {{{#!php
 <?php
 if(empty($page_obj)) return false;

 }}}


 the error went away.I don't know if there is any other effects ,hope
 somebody can fix this bug later.

 my wordpress version is :4.7.4

--
Ticket URL: <https://core.trac.wordpress.org/ticket/27015#comment:13>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list