WordPress.org

Ready to get started?Download WordPress

Forums

Limit wp_get_archives to show certain number of words per line (8 posts)

  1. AkaMaDdiSk
    Member
    Posted 5 years ago #

    Hi, I'm trying to use wp_get_archives to display a list of recent posts. I understand there is a "limit" parameter that you can use to set the maximum number of posts that it displays. However, is there a way to specify the number of words per post title? Basically I would like the list of recent post to be one line each. If the title of a recent posts is longer than, say, 6 words, then I would like for it to only show "..." in place of the remaining words in the title.

    How can this be done?

    Much thanks.

  2. MichaelH
    Member
    Posted 5 years ago #

  3. AkaMaDdiSk
    Member
    Posted 5 years ago #

    Thanks for this. But this seems to be only targetted for the_excerpt and the_content. I'm trying to limit words for the_title.

    Any other ideas?

  4. AkaMaDdiSk
    Member
    Posted 5 years ago #

    Does anyone have any ideas? I have a list of recent posts on my sidebar but instead of showing the whole title I'd like for it to show a limited number of characters:

    >> This is the first post that...
    >> Here comes the next post of...
    >> Another example post here to...

    Something like the above.

    Currently in my template I'm using this

    <?php wp_get_archives('title_li=&type=postbypost&limit=8'); ?>

    Any help would be appreciated.

  5. AkaMaDdiSk
    Member
    Posted 5 years ago #

    Anyone know this?

  6. AkaMaDdiSk
    Member
    Posted 5 years ago #

    Apologies for the bump....anyone?

  7. AkaMaDdiSk
    Member
    Posted 5 years ago #

    Any help please?

  8. iridiax
    Member
    Posted 5 years ago #

    I don't see how you can do this with wp_get_archives due to this template tag's output and because it is not a built in parameter.

    Although it would require knowing/learning some php, you may be able to do it with a second loop and using the_title() as a php variable with display set to false in php substr to limit the number of characters. There are ways to do so, but I haven't learned yet how to limit the number of words with php.

Topic Closed

This topic has been closed to new replies.

About this Topic