wordpress-seo icon indicating copy to clipboard operation
wordpress-seo copied to clipboard

Shortcodes not being parsed correctly when render function uses global $post

Open brahmadpk opened this issue 9 years ago • 1 comments

Please give us a description of what happened.

Hello, I have a shortcode in my page which outputs content based on the current page. There is no other content in the page. The shortcode render function uses the global $post to determine the content to be returned. This works exactly as desired on the frontend.

However, on the backend, yoast SEO plugins says "The text contains 0 words. This is far below the recommended minimum of 300 words. Add more content that is relevant for the topic."

When I change the plugin to not refer to global $post but pass the required data as attributes in the shortcode, yoast SEO works correctly.

Please describe what you expected to happen and why.

I expect yoast SEO to parse the shortcode correctly even when the shortcode render function uses global $post.

Technical info

  • WordPress version: 4.8.1
  • Yoast SEO version: 5.2

brahmadpk avatar Aug 12 '17 10:08 brahmadpk

The global $post is not available in the admin, so you should be passing the required data as attributes in the shortcode.

tacoverdo avatar Aug 14 '17 09:08 tacoverdo