I am trying to make a WordPress theme, following the Wordpress Coding Standards - WPCS. In functions.php, I have a function to get only the teaser (text above the read more-tag). The function works, however I get an error from Code Sniffer that
Overriding WordPress globals is prohibited
Any suggestions on how to achieve this, while following the Coding Standards would be great!
global $more; $more_saved = $more; // Sets $more to not showing the content after the more tag. $more = 0; echo esc_html( get_the_content( '', false ) ); // Restores $more. $more = $more_saved;