如何在wordpress中显示页面的有限内容

如何在wordpress中显示页面的有限内容,wordpress,Wordpress,我有代码显示页面的内容和“标题”。我只想显示该页面内容的150个单词 这是我的密码 <?php $args = array( 'include' => 1319, 'post_type' => 'page', 'post_status' => 'publish' ); $mypages = get_pages($args); foreach($mypages as $page) { $content = $page->p

我有代码显示页面的
内容
和“标题”。我只想显示该页面内容的150个单词

这是我的密码

<?php 
$args = array(
   'include' => 1319,
   'post_type' => 'page',
   'post_status' => 'publish'
 );  
$mypages = get_pages($args); 

foreach($mypages as $page)
{   

    $content = $page->post_content;

    $content = apply_filters('the_content', $content);
?>

<div class="page_botheadingtop">
<?php echo $page->post_title ?>
</div>
<div class="page_botheadingmiddle">
<?php echo $page->post_content;  ?>
</div>

<div class="page_botheadingbottom">
<a href="<?php echo get_page_link($page->ID) ?>">Read More..</a>
</div>



<?php
}   

此代码显示id为1319的页面的所有内容。我只想显示150字,请提供建议

我将非常感谢你 我在等你的答复 谢谢使用

<?php
the_excerpt_max_charlength(140);

 function the_excerpt_max_charlength($charlength) {
$excerpt = get_the_excerpt();
$charlength++;

if ( mb_strlen( $excerpt ) > $charlength ) {
    $subex = mb_substr( $excerpt, 0, $charlength - 5 );
    $exwords = explode( ' ', $subex );
    $excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) );
    if ( $excut < 0 ) {
        echo mb_substr( $subex, 0, $excut );
    } else {
        echo $subex;
    }
    echo '[...]';
} else {
    echo $excerpt;
}
}
?>


<?php
$my_excerpt = get_the_excerpt();
if ( $my_excerpt != '' ) {
// Some string manipulation performed
 }
 echo $my_excerpt; // Outputs the processed value to the page
 ?>