WPIntell

Source evidence

Problem with $post global variable

Content No Cache | Serve uncached partial content even when you add it to a page that is fully cached. · support · 2023-05-31T06:36:00+00:00

mixedsentiment
mediumseverity
0.84relevance
2replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

6 / 35 rows with source links

17.1% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

29 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
raperez resolved
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! Hi @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 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 2 years, 11 months ago by raperez .

Comments

2 shown
Jose Mortellaro 2023-05-31T13:59:00+00:00

Hi @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

raperez 2023-06-05T10:02:00+00:00

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 2 years, 11 months ago by raperez .