首页 > 解决方案 > why are two paragraphs being added on wordpress custom excerpt function used?

问题描述

I'm trying to develop wordpress site, where I'm using a custom excerpt function at front-end to display my post content. code is the following:

<h5 class="post-title"><a href=" <?php the_permalink() ?> "> <?php the_title() ?> </a></h5>
<?php the_post_thumbnail('home') ?>
<p class="content excerpt"> <a href="<?php the_permalink() ?>"> <?php news_excerpt(25) ?> </a></p><hr />

But, the problem is that two content showing paragraphs are adding at browser output. The output is the following:

<p class="content excerpt"> <a href="http://localhost/wordpress/index.php/2021/01/11/%e0%a6%9f%e0%a6%bf%e0%a6%95%e0%a6%be-%e0%a6%aa%e0%a7%87%e0%a6%a4%e0%a7%87-%e0%a7%a8%e0%a7%ac-%e0%a6%9c%e0%a6%be%e0%a6%a8%e0%a7%81%e0%a7%9f%e0%a6%be%e0%a6%b0%e0%a6%bf-%e0%a6%a5%e0%a7%87%e0%a6%95/"> <!-- wp:paragraph -->
<p>চলতি মাসের ২১ থেকে ২৫ তারিখের মধ্যে দেশে করোনাভাইরাসের টিকা আসবে। আর এই টিকা দেওয়া শুরু হবে ফেব্রুয়ারির প্রথম সপ্তাহে। এ জন্য নিবন্ধন </a></p>

How can I solve this problem? Thank you.

标签: phpwordpress

解决方案


使用此功能对内容进行段落操作: wpautop( string $pee, bool $br = true )

https://developer.wordpress.org/reference/functions/wpautop/


推荐阅读