I am new to php and trying to trim the lines of text generated by the ('information') part of the code seen below (in my custom WP theme):
<div class="information"><?php echo get_post_meta(get_the_ID(),'information',true); ?></div>
Each post has a different lenght of it's information (basically like a excerpt, but pulled from a custom field in each post) text, which messes up my archive/blog page, as i use a 3 columns grid. I need the lenght of all posts seen on the archive page to be equally long, by restricting the "information" text to be no more than lets say 150 characters long.
I see the fenction in this piece of code for example, taken from a default WP file, but can't seem to wrap it around my own piece of code seen above, to make it work like i want it to:
<?php
et_divi_post_meta();
if ( 'on' !== et_get_option( 'divi_blog_style', 'false' ) || ( is_search() && ( 'on' === get_post_meta( get_the_ID(), '_et_pb_use_builder', true ) ) ) ) {
truncate_post( 270 );
} else {
the_content();
}
?>
This is what i want/talk about:
Before:
POST 1 I am a wordpress post, with a long text, that should not be so long, as it makes the 3 column setup of the archive page look stupid.
After:
POST 1 I am a wordpress post, with a long text, that should not be so long...
How do i do this?
Thanks!