I used get_pages() to get the content of the child pages of a page. Although the excerpt can also be an answer but is there any other way to display the contents of the page before the more tag when I use the get_pages()?

1 Answer 1


You can use the WordPress function get_extended to fetch the different parts of a string (the part before and the part after the <!--more--> tag). get_extended returns an array with three keys, of which the keys main and extended are important: $arr['main'] contains the part before the more tag, and $arr['extended'] the part after the more tag.

This would yield something like:

// Fetch post content
$content = get_post_field( 'post_content', get_the_ID() );

// Get content parts
$content_parts = get_extended( $content );

// Output part before <!--more--> tag
echo $content_parts['main'];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.