• Resolved xoogu

    (@xoogu)


    In this thread: https://www.ads-software.com/support/topic/mfunc-still-not-working/page/2?replies=13#post-4314177

    Frederick says <q>mfunc code can only be used with theme template files, post/page content or widget areas</q>

    I realise that shortcodes aren’t mentioned there, however since the post/page content includes parsed shortcodes, I am surprised that MFunc doesn’t work.

    If I have a shortcode handler that outputs the following:

    return '<!-- mfunc '.W3TC_DYNAMIC_SECURITY.' -->
    		echo mt_rand(1,10000);
    <!-- /mfunc '.W3TC_DYNAMIC_SECURITY.' -->'

    When I visit the page including the shortcode, I will see the random number. However, this is cached as part of the page – if I reload the page I still see the same number.

    It would be really nice to be able to use mfunc output by a shortcode.

    Also, being able to filter the page cache key (_getPage_key()) would be really useful too.

    Sometimes you’ll have dynamic content that can change on each request, which mfunc would be good for. Other times you’ll have dynamic content that will be the same for sets of visitors, in which case being able to filter the page key would be more efficient.

    https://www.ads-software.com/plugins/w3-total-cache/

Viewing 1 replies (of 1 total)
  • Thread Starter xoogu

    (@xoogu)

    My bad, the page fragment caching does work with shortcode output. It just looked like it wasn’t working because each time I refreshed the page I was getting the same content rather than the dynamic content. This was due to W3TC sending a 304 Not Modified header – actually very sensible.

    Still, being able to filter the page key without having to edit the plugin file would be very useful.

Viewing 1 replies (of 1 total)
  • The topic ‘MFunc not working with shortcode output’ is closed to new replies.