WordPress.org

Support

Support » Plugins and Hacks » [Plugin: W3 Total Cache] I get 'Array' as the count of views if w3tc is active while publi

[Plugin: W3 Total Cache] I get 'Array' as the count of views if w3tc is active while publi

  • georgynjoseph

    @georgynjoseph

    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

Viewing 5 replies - 1 through 5 (of 5 total)
  • georgynjoseph

    @georgynjoseph

    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!!!

    tgeorge

    @tgeorge

    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.

    georgynjoseph

    @georgynjoseph

    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?

    tgeorge

    @tgeorge

    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 -->
    Plugin Author Frederick Townes

    @fredericktownes

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: W3 Total Cache] I get 'Array' as the count of views if w3tc is active while publi’ is closed to new replies.