WordPress.org

Ready to get started?Download WordPress

Forums

how to use plugins hook (custom caching) in wp-supercache? (6 posts)

  1. zefefre
    Member
    Posted 6 years ago #

    Hi, I would like to exclude some plugins from being cached, in particular wp-postviews (http://wordpress.org/extend/plugins/wp-postviews/) but have no idea how to do it.

    I'm using wp-postviews 1.02 and it has this function to count the views.

    ### Function: Calculate Post Views
    add_action('loop_start', 'process_postviews');
    function process_postviews() {
    	global $id;
    	$post_views = intval(post_custom('views'));
    	if(empty($_COOKIE[USER_COOKIE])) {
    		if(is_single() || is_page()) {
    			if($post_views > 0) {
    				update_post_meta($id, 'views', ($post_views+1));
    			} else {
    				add_post_meta($id, 'views', 1);
    			}
    		}
    	}
    }

    Could anyone give me some directive how to make it always count the post views even when caching is enabled? What should i put inside 'wp-super-cache\plugins' ?

    Thanks in advance.

  2. Donncha O Caoimh
    Member
    Posted 6 years ago #

    zefefre - if you still want to use caching, and especially the static caching of the super cache plugin, then the pageviews plugin will have to be modified to use Javascript.

    If you just want to use the regular WP-Cache caching then use the "mclude" and "mfunc" tags.

  3. zefefre
    Member
    Posted 6 years ago #

    Thanks for your response donncha. :)

    I think for now I'll just try using regular WP-Cache with mclude and mfunc as I have no idea how to modify the pageviews plugin to use Javascript.

  4. Lester Chan
    Member
    Posted 6 years ago #

    donncha: Do you have a rough guide or tutorial on how to use the js?

  5. Donncha O Caoimh
    Member
    Posted 6 years ago #

    GamerZ - I don't have a guide or tutorial but look at the source code of my blog at http://ocaoimh.ie/ and search for the string "referer". That bit of Javascript code creates a tiny 1x1 image out of my counter script.

  6. Lester Chan
    Member
    Posted 6 years ago #

    donncha: thanks dude =)

Topic Closed

This topic has been closed to new replies.

About this Topic