Last active
August 30, 2023 05:41
-
-
Save atomtigerzoo/5695175dadd8dac9f6a8 to your computer and use it in GitHub Desktop.
Wordpress: split the_content into parts at more-shortcode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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