WordPress.org

Support

Support » Themes and Templates » [Resolved] Adjust excerpt length to certain height

[Resolved] Adjust excerpt length to certain height

  • Marijn Bent
    Participant

    @marijn-bent

    Hi everyone,

    I’m searching for something that adjust the excerpt length till it reach a certain height. For example:
    height: 100px
    An excerpt with short words; a length of 50 words
    An excerpt with long words; a length of 30 words

    Both excerpts are 100px high. Can somebody help me with something like this? I can’t find anything how to make this.

    Thanks,

    Marijn

Viewing 5 replies - 1 through 5 (of 5 total)
  • WPyogi
    Forum Moderator

    @wpyogi

    You may be able to do this in the CSS code — with the set height and ‘overflow: hidden;’

    What if you define a bigger excerpt length and put the text inside a div with overflow: hidden ?
    You could define a line-height for that div, and the height would be a multiplier of the line-height, so that a line of text wouldn’t appear in half.

    Just an ideia…

    same ideia wpyogi 🙂

    esmi
    Forum Moderator

    @esmi

    Sorry but I don’t think this is even possible, There are just way too many variables. For example, “it” is one word but so is “disestablishmentarianism”. 55 of the former take up far less space than 55 of the latter! Then, what font size is the user viewing the page at? Using what screen resolution or browser zoom level?

    I think your best bet is to have a fixed excerpt word length and then use overflow:hidden; in the CSS for the excerpt container. Providing any “read more” link is displayed outside the excerpt container, this should give you a decent display.

    Marijn Bent
    Participant

    @marijn-bent

    Thanks for all your comments!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] Adjust excerpt length to certain height’ is closed to new replies.