get_extended Description
Gets extended content information from a post body that contains a <!--more--> tag.
The returned array contains the keys main and extended. The value of main is the content before <!--more-->, and the value of extended is the content after <!--more-->.
get_extended Usage
<?php get_extended( $post_content ) ?>
get_extended Parameters
| Parameter | Type | Required | Description | Default |
|---|---|---|---|---|
| $post_content | string | Yes | Post content | None |
get_extended Return Value
(array): The content before the more tag (main) and the content after the more tag (extended).
get_extended Example
Display a short summary of the latest article
If you want to show the latest posts on your WordPress site but only display the content before the <!--more--> tag, you can output it like this:
<ul>
<?php
global $post;
$args = array( 'numberposts' => 5 );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata( $post );
$content_arr = get_extended (get_the_content() ); ?>
<li>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</br>
<?php echo $content_arr['main']; //显示more标签之前的内容 ?>
</li>
<?php endforeach; ?>
</ul>
Note: $content_arr['extended'] contains the content after the more tag.
