get_extended

Get extended entry info ().

Description

(array) get_extended( (string) $post ); 

There should not be any space after the second dash and before the word more,. There can be text or space(s) after the word more,, but won't be referenced.

The returned array has main , extended., and more_text keys. Main has the text before the . The extended. key has the content after the comment. The more_text key has the custom Read More text.

Returns (array)

Post before ('main'), after ('extended'), and custom read more ('more_text').

Parameters (1)

0. $post (string)
Post content.

Usage

  1. if ( !function_exists( 'get_extended' ) ) { 
  2. require_once ABSPATH . WPINC . '/post.php'; 
  3.  
  4. // Post content. 
  5. $post = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_extended($post); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/post.php  
  1. function get_extended( $post ) { 
  2. //Match the new style more links. 
  3. if ( preg_match('/<!--more(.*?)?-->/', $post, $matches) ) { 
  4. list($main, $extended) = explode($matches[0], $post, 2); 
  5. $more_text = $matches[1]; 
  6. } else { 
  7. $main = $post; 
  8. $extended = ''; 
  9. $more_text = ''; 
  10.  
  11. // leading and trailing whitespace. 
  12. $main = preg_replace('/^[\s]*(.*)[\s]*$/', '\\1', $main); 
  13. $extended = preg_replace('/^[\s]*(.*)[\s]*$/', '\\1', $extended); 
  14. $more_text = preg_replace('/^[\s]*(.*)[\s]*$/', '\\1', $more_text); 
  15.  
  16. return array( 'main' => $main, 'extended' => $extended, 'more_text' => $more_text );