最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - wp_trim_words() does not work with my code Am I doing any mistake in my code?

programmeradmin5浏览0评论

n my WordPress website, I want to show a short text of each blog_post on the custom blog template. I want to show a Read More button with a link to the post at the end so a user can click on that link and view the full post.

But I am always getting the whole post instead of its summary.

Here is my code:

  <div class="contentTitle">
      <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    </div>
  <div class="contentText">
    <?php 
    $readmore = '<p><a href="'.get_permalink().'"></a></p>';
    echo wp_trim_words( get_the_content(), 3, $readmore ); ?>
  </div>
<?php endwhile; ?>

Am I doing any mistake in my code?

发布评论

评论列表(0)

  1. 暂无评论