Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I currently have a plugin that lets me display a random post in a widget. The problem is that if I activate w3 total cache it will only display that post as long as the cache hasn't been cleared. Is there a way to cache everything except this plugin?

Sorry if the question is rather newbie, I just installed the plugin but haven't been able to find the answer anywhere.

Thanks in advance!

share|improve this question

1 Answer 1

up vote 4 down vote accepted

You can try fragment caching, from plugin's FAQ:

Edit your templates to with the following syntax to ensure that dynamic features remain so:
Example 1:
<!-- mfunc any PHP code --><!-- /mfunc -->
Example 2:
<!-- mfunc -->any PHP code<!-- /mfunc -->
Example 3:
<!--MFUNC           -->
                                      echo rand();
<!--/mfunc -->
Example 4:
<!-- mclude path/to/file.php --><!-- /mclude -->
Example 5:
<!-- mclude -->path/to/file.php<!-- /mclude -->

But my personal opinion is just to get rid of overly dynamic stuff. Unless it's key functionality (like in e-commerce) it's usually useless eye candy.

share|improve this answer
    
I understand, the problem is that this random post displays a random featured ad that users pay to have it there, if I only display 1 it loses the whole purpose. Let me test that approach, thanks a lot. –  javiervd Mar 26 '11 at 20:40
    
Sorry the above didn't work, I don't know if I might be doing it wrong. What I wanted to do was basically disable cache on my sidebar so I did: <!-- mclude --> <div id="sidebar"> //Sidebar content </div> <!-- /mclude --> But it still caches it. –  javiervd Mar 26 '11 at 20:55
    
@javiervd mclude is for including files, try wrapping code in mfunc ones (examples 2-3). –  Rarst Mar 26 '11 at 20:57
    
Thanks @Rast, using mfunc throwed me an error but I used <!-- mclude /wp-content/themes/mytheme/sidebar.php --><!-- /mclude --> and it worked just fine. –  javiervd Mar 27 '11 at 1:56
    
<!-- mfunc PHPCODE --><!-- /mfunc --> doesn't (seem) to work for plugins. When I do this, my page doesn't actually contain the code I expect. –  Alan Mar 8 '13 at 0:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.