Title: global $post variable is being set
Last modified: August 30, 2016

---

# global $post variable is being set

 *  Resolved [njs](https://wordpress.org/support/users/njs/)
 * (@njs)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/global-post-variable-is-being-set/)
 * Hi
    I have updated the plugin to v3.4.3 and am now experiencing the following
   problem…
 * I have a custom function that runs within a wp_query loop and it calls wp_get_attachment_image_src().
   This must in turn make use of the _Custom Upload Dir_ plugin, which is overriding
   the loop’s $post variable with the ID of the current page (I need it to remain
   the ID of the current post in the loop).
 * Line 198 of custom_upload_dir.php seems to be the culprit:
 *     ```
       if($postID){
           $post = get_post($postID);
       } ...
       ```
   
 * Is there a possible solution to this?
 * [https://wordpress.org/plugins/custom-upload-dir/](https://wordpress.org/plugins/custom-upload-dir/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [ulfben](https://wordpress.org/support/users/ulfben/)
 * (@ulfben)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/global-post-variable-is-being-set/#post-6460652)
 * Good catch.
 *  Plugin Author [ulfben](https://wordpress.org/support/users/ulfben/)
 * (@ulfben)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/global-post-variable-is-being-set/#post-6460653)
 * Updated 3.4.3.1 and trunk with this fix. Re-download in five minutes or so, and
   let me know.
 *  Thread Starter [njs](https://wordpress.org/support/users/njs/)
 * (@njs)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/global-post-variable-is-being-set/#post-6460730)
 * That seems to have fixed it. Nice one and thanks!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘global $post variable is being set’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/custom-upload-dir.svg)
 * [Custom Upload Dir](https://wordpress.org/plugins/custom-upload-dir/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/custom-upload-dir/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/custom-upload-dir/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-upload-dir/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-upload-dir/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-upload-dir/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [njs](https://wordpress.org/support/users/njs/)
 * Last activity: [10 years, 9 months ago](https://wordpress.org/support/topic/global-post-variable-is-being-set/#post-6460730)
 * Status: resolved