I want to show some content of post in anchor tag and show as link but I have use wp_trim_words
function I don't know how to allow the html tags.
$more = ' <a href="'. get_permalink( get_the_ID() ) . '" class="readMoreBtn">Read More</a>';
$content = wp_trim_words( get_the_content(), 50, $more );
echo do_shortcode($content);
Thanks to @dingo_d but he missed wpautop() in the code. Here is the updated code.
$more = ' <a href="'. get_permalink( get_the_ID() ) . '" class="readMoreBtn">Read More</a>';
echo force_balance_tags( html_entity_decode( wp_trim_words( htmlentities( wpautop(get_the_content()) ), 100, $more ) ) );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With