So I've been looking for a solution for quite some time. But can't find it somehow.
What I need is a function that shows a specific amount of characters from the content, instead of a specific number of words. Because words can be longer than other words and I want to keep the styling from the post preview equal.
Now I'm still using trim words:
<p><?php echo wp_trim_words( get_the_content(), 15 ); ?></p>
Does anyone know how I can trim characters from the content of a post instead of the amount of words?
Thank you in advance!
Update:
Here is my complete posts section:
<?php
$args = array(
'post_type' => 'post',
'posts_per_page' => 3,
'category__in' => array(2, 3),
'post__not_in' => array( $post->ID ),
);
?>
<?php $query = new WP_Query($args); ?>
<?php if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post(); ?>
<a href="<?php the_permalink();?>">
<div class="post">
<?php $thumb = get_the_post_thumbnail_url(); ?>
<div class="post-image" style="background-image:url('<?php echo $thumb;?>');"></div>
<div class="post-prev">
<?php
foreach (get_the_category() as $category){
echo "<span>";
echo $category->name;
echo "</span>";
} ?>
<h2>
<?php
$thetitle = $post->post_title;
$getlength = strlen($thetitle);
$thelength = 20;
echo substr($thetitle, 0, $thelength);
if ($getlength > $thelength) echo "..";
?>
</h2>
<p><?php echo wp_trim_words( get_the_content(), 15 ); ?></p>
<span class="btn">Lees verder</span>
</div>
</div>
</a>
<?php endwhile; wp_reset_postdata(); else : ?>
<p><?php _e("Geen content gevonden.."); ?></p>
<?php endif; ?>