WordPress.org

Ready to get started?Download WordPress

Forums

W3 Total Cache
I get 'Array' as the count of views if w3tc is active while publi (6 posts)

  1. georgynjoseph
    Member
    Posted 2 years ago #

    Hi friends,

    I use w3tc and i also use popular posts plugin (http://rmarsh.com/plugins/popular-posts-plugin/) and the following code to print the number of views a post had, just under the post title.

    <?print(" ------ ");?><?php echo popular_posts_views(); ?> <?print("views");?>

    But my problem is that if W3TC is active while i publish a post, i only get "Array Views" instead of "1 views" or "2 views".
    Have a look under this post title - http://www.turnbacktogod.com/peters-declaration-about-jesus/

    So each time before i publish a post, i deactivate W3TC and then publish the post and then activate W3TC.

    Can anyone help me to save this much trouble?

    Thanks,
    Georgy

  2. georgynjoseph
    Member
    Posted 2 years ago #

    When i posted the same query in DP Forums, this is the answer i got :(

    http://forums.digitalpoint.com/showthread.php?t=1895881

    But i dont want to leave the best cache plugin W3TC and go for DB Cache reloaded, as he suggests me there:(

    Please help!!!

  3. tgeorge
    Member
    Posted 2 years ago #

    There is a way to disable caching of a particular section of a page using MFUNC. Here is how. Replace this code :

    <?php echo popular_posts_views(); ?>

    with this code :

    <?php
    <!-- mfunc -->
    echo popular_posts_views();
    <!-- /mfunc -->
    ?>

    I cannot test this myself. I hope it works.

  4. georgynjoseph
    Member
    Posted 2 years ago #

    I tested with this code; but it gives me only a white screen with this error when i view a post;

    Parse error: syntax error, unexpected '<' in /home/georgy/public_html/wp-content/themes/tiga-06/single.php on line 61

    any syntax problem in the code you gave me to try?

  5. tgeorge
    Member
    Posted 2 years ago #

    Hmm... I guess Frederick was wrong when he said to put PHP start and end tags outside of MFUNC. They clearly have to be inside of MFUNC. Try this :

    <!-- mfunc -->
    <?php
    echo popular_posts_views();
    ?>
    <!-- /mfunc -->
  6. Frederick Townes
    Member
    Plugin Author

    Posted 2 years ago #

    For now W3TC's fragment caching is called before WP is loaded so these kinds of calls will fail.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic