I dont want to show image in my read_more function in homepage. read_more shows first 25 strings of my content. when I add image in the content it shows with the string inline. I don't want the image. Anyone know how to do it? here is my code below..
<div id="leadnewsbox" class="col-md-5 col-sm-4 col-xs-12">
<?php
$breakingcat = get_the_category_by_id($btimes['breaking-news-category']);
$breakingnews = new WP_Query(array(
'post_type' => 'post',
'posts_per_page' => 1,
'category_name' => $breakingcat
));
while($breakingnews->have_posts()) : $breakingnews->the_post(); ?>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('post-image'); ?></a>
<div class="leadnewsboxtitle">
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p><?php read_more(25); ?>...</p>
</div>
<?php endwhile; ?>
// read_more function
function read_more($limit){
$content = explode(' ', get_the_content());
$less_content = array_slice($content, 0 , $limit);
echo implode (' ', $less_content);
}
read_more()
. This likely callsthe_excerpt()
for displaying the partial. It's possible to filter that output and remove an<img>
tag before output.