Languages: English • Italiano • 日本語 Русский • (Add your language)
Get extended entry info (<!--more-->).
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' and 'extended' keys. Main has the text before the <!--more-->. The 'extended' key has the content after the <!--more--> comment.
<?php $result = get_extended( $post_content ) ?>
If you want to display the latest posts on your WordPress blog, but only the content which comes before the <!--more--> tag, you can use this:
<ul> <?php global $post; $args = array( 'numberposts' => 5 ); $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata( $post ); $content_arr = get_extended ( $post->post_content ); ?> <li> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> </br> <?php echo $content_arr['main']; //Display the part before the more tag ?> </li> <?php endforeach; ?> </ul>
Note: $content_arr['extended'] contains the contents after the more tag.
Since: 1.0.0
get_extended() is located in wp-includes/post.php
.