WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question

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

function new_excerpt_length($length) { 
    return 100; // change this to how many any characters you want

add_filter('excerpt_length', 'new_excerpt_length');

Manually controlling the excerpt Howto 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.

share|improve this answer

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:

function excerpt($num) {
    echo utf8_encode(substr(get_the_excerpt(), 0, $num+1)) . "...";

and then call it with:


this way you'll get the first 55 characters followed by ... overflow:hidded; may also help.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.