georgynjoseph
Member
Posted 8 months 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
georgynjoseph
Member
Posted 8 months 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!!!
tgeorge
Member
Posted 8 months 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.
georgynjoseph
Member
Posted 8 months 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?
tgeorge
Member
Posted 8 months 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 -->
For now W3TC's fragment caching is called before WP is loaded so these kinds of calls will fail.