[wp-trac] [WordPress Trac] #41708: tax_query not (instantly) available from functions.php

WordPress Trac noreply at wordpress.org
Tue Aug 22 21:59:23 UTC 2017


#41708: tax_query not (instantly) available from functions.php
----------------------------+--------------------------
 Reporter:  Digital Noises  |       Owner:
     Type:  defect (bug)    |      Status:  closed
 Priority:  normal          |   Milestone:
Component:  General         |     Version:  4.8.1
 Severity:  normal          |  Resolution:  invalid
 Keywords:                  |     Focuses:  performance
----------------------------+--------------------------
Changes (by boonebgorges):

 * status:  new => closed
 * resolution:   => invalid
 * milestone:  Awaiting Review =>


Comment:

 Hi @Digital Noises - Thanks for the ticket, and welcome to WordPress Trac.

 Taxonomies and post types cannot be reliably referenced until after the
 `init` hook, which is when WordPress and most plugins register them. If
 you need to perform some logic on every pageload that requires a
 `WP_Query` or `tax_query`, `wp_loaded` is the first recommended place to
 do it.

 `wp_head` runs much later, and will work fine as long as you don't need to
 perform a redirect or any other actions that'd result in "headers already
 sent" messages; at this point, WP has already begun to build the HTML
 page.

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


More information about the wp-trac mailing list