Title: Get Post Object before $wp_query is set
Last modified: September 6, 2016

---

# Get Post Object before $wp_query is set

 *  [ColdJackle](https://wordpress.org/support/users/coldjackle/)
 * (@coldjackle)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/get-post-object-before-wp_query-is-set/)
 * Hello Guys,
 * im struggeling with getting the current post object in the filter “option_active_plugins”.
   The gloabls for $wp_query, $post,… are not set at the time the filter is called.
   So while WordPress needs to set them based on some data too, I was wondering 
   how one would get the current context before the $wp_query is set (which therefore
   makes most of the relevant wordpress functions unusable).
 * Note: Im running the filter function in a mu-plugin, so it get’s called early
   enough. I thought this wouldn’t be a problem. Also the documentation on the “
   option_<name>” filters has example code using wp_query functions. What makes 
   my filter so special?
 * Here is the register code, loaded in a mu-plugin:
 *     ```
       function pr_disable_plugin_routine($plugins)
       {
       	global $wpdb,/*set*/
               $wp_query; /*not set*/
   
               ...
   
       	return $plugins;
       }
       add_filter( 'option_active_plugins', 'pr_disable_plugin_routine' );
       ```
   
 * I’ve allready tried every global I could imagine, to at least grab an id from
   an index.php redirect or something like that. No solution so far.
 * Thanks in advance

Viewing 1 replies (of 1 total)

 *  Thread Starter [ColdJackle](https://wordpress.org/support/users/coldjackle/)
 * (@coldjackle)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/get-post-object-before-wp_query-is-set/#post-8150277)
 * EDIT: Couldn’t find the edit-button, sorry 🙁
 * The tags are wrong, I hit enter to early. Also Id’ like to add, that it’s not
   explicit the post object that I need, more of the current context or some data
   to work with. I’d like to know what site the user is on, without reparsing the
   whole url (which also doesn’t work with the functions i tried, like “url_to_postid”).

Viewing 1 replies (of 1 total)

The topic ‘Get Post Object before $wp_query is set’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [ColdJackle](https://wordpress.org/support/users/coldjackle/)
 * Last activity: [9 years, 9 months ago](https://wordpress.org/support/topic/get-post-object-before-wp_query-is-set/#post-8150277)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
