Php 如何为每篇文章将“阅读更多”按钮硬编码到WordPress最新新闻循环中?

Php 如何为每篇文章将“阅读更多”按钮硬编码到WordPress最新新闻循环中?,php,wordpress,Php,Wordpress,在我的WordPress网站上,我使用以下代码循环我的最新帖子: <?php if ( is_single() ) : the_title( '<h1 class="entry-title">', '</h1>' ); else : the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '"

在我的WordPress网站上,我使用以下代码循环我的最新帖子:

    <?php
    if ( is_single() ) :
        the_title( '<h1 class="entry-title">', '</h1>' );
    else :
        the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
    endif;

    if ( 'post' === get_post_type() ) : ?>
    <div class="entry-meta">
        <?php blogtristan_posted_on(); ?> <span class="loopdivide"> | <span class="loop-time"><?php the_time( 'H:i' );?></span> (GMT)

    </div><!-- .entry-meta -->
    <?php
    endif; ?>
</header><!-- .entry-header -->

    <div class="entry-content">
    <?php
$post = $post->post_content; /* or you can use get_the_title() */
$getlength = strlen($post);
$thelength = 200;
echo substr($post, 0, $thelength);
if ($getlength > $thelength) echo "...";
?>

请尝试以下代码

if (strlen($getlength) > 200) {
   echo '<a href="' . get_the_permalink(get_the_ID()) . '" title="">Read more</a>';
}else{
  echo $post;
}
if(strlen($getlength)>200){
回声';
}否则{
echo$post;
}