Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atomtigerzoo/5695175dadd8dac9f6a8 to your computer and use it in GitHub Desktop.
Save atomtigerzoo/5695175dadd8dac9f6a8 to your computer and use it in GitHub Desktop.
Wordpress: split the_content into parts at more-shortcode
function atz_split_content_at_more(){
// Split the content
$content_parts = preg_split('/<span id="more-\d+"><\/span>/i', get_the_content());
// Grab first part of content and apply filters
$result['intro'] = apply_filters('the_content', array_shift($content_parts));;
// Content has a more part?
if(!empty($content_parts)):
$result['more'] = apply_filters('the_content', implode($content_parts));
endif;
return $result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment