I am using page caching with W3 Total Cache. Using the Disk caching method with late initialization, W3 total cache allows you to use comment tags <!-- mfunc {uniquephrase} -->
to get the server to process PHP within these tags, exempt from the rest of the page. It is called page fragment cache.
I am trying to load and display comments on an otherwise fully cached page, by using these comment tags. This code is not inside a <?php
tag, as per the documentation.
<!-- mfunc {phrase} -->
$arr = get_comments(array("post_id" => get_queried_object_id(),"status" => "approve",));
wp_list_comments( $args = array(), $arr);
<!-- /mfunc {phrase}-->
The idea of this code is to get comments for the current post, with status approve.
The code has problems getting the post ID from within this block.
- The first, uncached pageload, successfully gets the page post ID.
- Thereafter, cached post does not get the ID.
- Using code
echo time()
correctly prints out the updating epoch timestamp - This suggests the problem is that codes to get the ID are not working.
Please can anyone point me in the direction of how to get the ID of the page from within the mfunc fragment?, am I missing something here?
1