Support » Plugins » [Plugin: WP Super Cache] Make some parts dynamic

  • Is there a way to make certain parts of the page stay dynamic? cause I want to make my rotating banner dynamic

Viewing 15 replies - 1 through 15 (of 17 total)
  • The easiest way is the oldest way: use Javascript and add your banner php script to the list of rejected URLs.

    In WP-Chache and Staticize Reloaded, there is this hack:

    <!--mfunc function_name('parameter', 'another_parameter') -->
    <?php function_name('parameter', 'another_parameter') ?>

    The HTML comments around the mirrored PHP allow it to be executed in the static page. To include another file try this:

    <!--mclude file.php-->
    <?php include_once(ABSPATH . 'file.php'); ?>

    I’d like to know if that would work on WP-Super Cache. Maybe that would help to those who don’t know (or don’t want) to get a java app.

    Update: I want to have some “Latest Posts” in my home page, but the Wp-Super Cache prevent it to work properly (caches that too).

    You don’t need to use Java. Use Javascript. Turn off the super cache part of the plugin (Half on), and disable compression. You can do the mclude stuff then but you lose out on staticly cached files.

    Do you know a good one for text/scroll?

    I’m using the Time Since plugin which displays the time for each post as “3 weeks, 1 day ago”.

    WP-Super-Cache seems to cache the date on every post until the scheduled clearing time (3600 seconds). I’m not sure which of the above methods you guys mentioned would allow me to make the following function dynamic (excluded from WP-Super-Cache):

    <?php if (function_exists('time_since')) {
    					echo time_since(abs(strtotime($post->post_date_gmt . " GMT")), time()) . " ago";
    					} else {
    					the_time('F jS, Y');
    				} ?>

    Is it at all possible?

    jimmiejo – best to use javascript really, r shorten the cache timeout to a minute or so..

    Would you be able to recommend how to implement javascript with a function like the one I posted above?

    I don’t have much experience with JS and am not quite sure how it could work. I’d love if you could share an example 🙂

    Think I figured it out, donncha:

    <script type="text/javascript">
    	document.write('<?php if (function_exists('time_since')) {
    		echo time_since(abs(strtotime($post->post_date_gmt . " GMT")), time()) . " ago";
    		} else {
    		the_time('F jS, Y');
    	} ?>');

    It seems to work (haven’t activated everything with wp-super-cache yet. Fingers crossed 🙂

    Hmmm…. that didn’t seem to do it. When Super Cache or Half is on, it is still caching the time with the above php in javascript.

    Your JS will have to do the calculation instead of PHP.

    That’s way out of my league and quite the pain for dynamic functions. Guess it’s a no go for the super cache plugin.

    Thanks anyways, Donncha.

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    If you really must write it in PHP, create a PHP file to do the calculation and output the HTML, then use javascript to include it into the page. This is pretty easy with jquery.

    <script type="text/javascript">
    jQuery(function($) {
    <div id="contentArea">... temporary loading message ...</div>

    Just make sure that you enqueue the jquery script in your functions.php or something. Like so: wp_enqueue_script('jquery');

    Thanks Otto, I’ll give that a try.

    Just an update: I noticed I have a few other dynamic functions in different sections of my site, so it’s not ideal to call on everything through javascript.

    Donncha suggested earlier setting the cache expiry to a minute or so, which I’ve done, and seems to do the trick with a steady flow of traffic. Hopefully it’s not too server intensive to cache large amounts of content so rapidly. Will have to wait and see.

    Thanks again to everyone for kindly replying.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘[Plugin: WP Super Cache] Make some parts dynamic’ is closed to new replies.