On my static frontpage, I would like to fetch the two latest posts as shown in this link.
Now the posts should always be displayed like this (i.e. constant height, limited number of characters), no matter what! If the post uses the more-tag or not – it should always look like in the picture.
How can that be achieved?
I tried both content and excerpt but somehow there always are cases in which the layout gets messed up. Is there a ‘standard’ way of doing this?
(I’m just asking about getting the actual content, i.e. the “text text text” bit – I have done all the rest)
Many thanks
The simple way to do this is to define the height/width in CSS of a container, and then apply a trim on the excerpt.
To change default excerpt length add this to you functions.php
Manually controlling the excerpt
How to control manual excerpt length?
Outside th loop
Using wp_trim_excerpt to get the_excerpt() outside the loop
The same filters can be applied to the content, but the excerpt suits this better.
I think that because the excerpt limits words and not characters you will always get different heights. You can limit the excerpt to number of characters to make it more accurate:
and then call it with:
this way you’ll get the first 55 characters followed by …
overflow:hidded; may also help.