Get full Worpress Content from a Post with ‘More’ block

The wordpress php function get_the_content(), when called from within the wordpress ‘loop’ will usually return the current post’s content – ‘very handy’ I hear you cry!  Indeed, but all is not as simple as it may seem.  If there is a <!–More–> block in the post it will not return the full text but instead will return some of the text with a link like ‘read more…’ inserted (what is displayed can be controled by an argument to the function). This is fine _unless_ you actually want to get the post’s full contents!!


Finding the answer to this seemingly simple question nearly drove me mad, but I eventually found a solution, there is a global flag called $more, setting this to 1 before calling get_the_content() or the_content() etc. will result in the <!–more–> blocks not being processed and all of the post’s text will be returned!


global $more;
$more = 1;
$content = get_the_content();