post_content)['main']; echo get_extended($p->post_content)['extended']; // with own function (wordpress own function has problems with enabled p tags) function wp_split_more($content, $type, $more_html = null) { $return = [ "before" => null, "after" => null ]; // split up if ( preg_match('//', $content, $matches) ) { list($return["before"], $return["after"]) = explode($matches[0], $content, 2); } else { $return["before"] = $content; $return["after"] = ''; } // clean up foreach($return as $key=>$value) { // remove whitespace $return[$key] = preg_replace('/^[\s]*(.*)[\s]*$/', '\\1', $return[$key]); // remove falsly opening p tag if( strpos($return[$key], "
") === 0 ) { $return[$key] = substr($return[$key], strlen("")); } // remove opening p tag if( strpos($return[$key], "") === 0 ) { $return[$key] = substr($return[$key], strlen("
")); } // remove closing p tag if( strrpos($return[$key], "
") === strlen($return[$key])-strlen("") ) { $return[$key] = substr($return[$key], 0, strlen($return[$key])-strlen("")); } } // add more tag if( $more_html !== null && $return["after"] !== "" ) { $return["before"] = $return["before"]." ".$more_html; } // add opening / closing p-tags $return["before"] = "".$return["before"]."
"; $return["after"] = "".$return["after"]."
"; return $return[$type]; } // example usage echo '