WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Adjust excerpt length to certain height (6 posts)

  1. Marijn Bent
    Member
    Posted 1 year ago #

    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

  2. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

    You may be able to do this in the CSS code -- with the set height and 'overflow: hidden;'

  3. David Beja
    Member
    Posted 1 year ago #

    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...

  4. David Beja
    Member
    Posted 1 year ago #

    same ideia wpyogi :)

  5. esmi
    Forum Moderator
    Posted 1 year ago #

    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.

  6. Marijn Bent
    Member
    Posted 1 year ago #

    Thanks for all your comments!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.