PHP code in meta description when using W3TC fragment caching
-
When using Yoast SEO together with W3TC and fragment caching is used and PHP fragment is located at the beginning of post content, Yoast SEO inserts fragment PHP code into meta descriptions (instead of processed code):
<meta property="og:description" content="...PHP code..."> <meta name="twitter:description" content="...PHP code...">To reproduce the problem configure W3TC to use fragment caching and then put some short piece of code at the top of the content where the description is taken from (start of the post).
For example, use this code (you can replace php code with W3TC_DYNAMIC_SECURITY with your ID):
<!-- mfunc <?php echo W3TC_DYNAMIC_SECURITY; ?> --> echo '<div>YOAST SEO TEST1</div>'; echo '<div>YOAST SEO TEST2</div>'; echo '<div>YOAST SEO TEST3</div>'; <!-- /mfunc <?php echo W3TC_DYNAMIC_SECURITY; ?> -->If you check meta descriptions you’ll see PHP code there.
It seems Yoast SEO takes (cached) page before it is processed by W3TC and PHP code is executed.
The topic ‘PHP code in meta description when using W3TC fragment caching’ is closed to new replies.