Title: Problem with $post global variable
Last modified: May 31, 2023

---

# Problem with $post global variable

 *  Resolved [raperez](https://wordpress.org/support/users/raperez/)
 * (@raperez)
 * [3 years ago](https://wordpress.org/support/topic/problem-with-post-global-variable/)
 * Hello:
 * First of all, thanks for such a great and useful plugin.
 * I have been using it to get some information in real time and it works perfectly
   well. I have been using $wpdb global variable without any problem, but unfortunately
   when using $post it seems to be always empty although it has been declared as
   global in the function.
 * Am I missing something? Could this be solved?
 * Thanks!

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

 *  Plugin Author [Jose Mortellaro](https://wordpress.org/support/users/giuse/)
 * (@giuse)
 * [3 years ago](https://wordpress.org/support/topic/problem-with-post-global-variable/#post-16783230)
 * Hi [@raperez](https://wordpress.org/support/users/raperez/)
 * for me, it’s difficult to understand what you are trying to do because I don’t
   know the code of your function.
 * However, I suggest you try to add the parameter request=”remote” to the shortcode.
   I mean the shortcode will look like [content_no_cache id=”xxx” request=”remote”]
 * Normally, CNC gets the content of the CNC element during an Ajax call directly
   from the database. Your $post variable may not work during the Ajax call. If 
   you add the parameter request=”remote”, CNC will get the content via a remote
   HTTP request, and in that case, the same $post variable may work. The content
   will appear a little later on the page, but you may solve the issue.
 * I hope it helps
 * Have a great day
 * Jose
 *  Thread Starter [raperez](https://wordpress.org/support/users/raperez/)
 * (@raperez)
 * [3 years ago](https://wordpress.org/support/topic/problem-with-post-global-variable/#post-16794018)
 * Hello:
 * I have created a shortcode to recover some data from a table. To search in this
   table, I must recover a value from the actual post (global $post) where the shortcode
   is located. Unfortunately, this variable is empty when called via no content 
   cache. I have also tried request=”remote” parameter with no luck.
 * When using the request=”remote” parameter my shortcode doesn’t work at all and
   I get an update error when trying to update the page where the shortcode is located.
 * Any other thing that could be done? Thanks again for your fantastic help!!
    -  This reply was modified 3 years ago by [raperez](https://wordpress.org/support/users/raperez/).

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

The topic ‘Problem with $post global variable’ is closed to new replies.

 * ![](https://ps.w.org/content-no-cache/assets/icon-256x256.png?rev=2687570)
 * [Content No Cache | Serve uncached partial content even when you add it to a page that is fully cached.](https://wordpress.org/plugins/content-no-cache/)
 * [Support Threads](https://wordpress.org/support/plugin/content-no-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/content-no-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/content-no-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/content-no-cache/reviews/)

## Tags

 * [post](https://wordpress.org/support/topic-tag/post/)

 * 2 replies
 * 2 participants
 * Last reply from: [raperez](https://wordpress.org/support/users/raperez/)
 * Last activity: [3 years ago](https://wordpress.org/support/topic/problem-with-post-global-variable/#post-16794018)
 * Status: resolved