WordPress.org

Ready to get started?Download WordPress

Forums

HungryFEED
[resolved] Truncate Title (8 posts)

  1. HFman
    Member
    Posted 2 years ago #

    Hi,
    I need a way to tuncate the title of each feed. Is there a truncate_title function?

    Thank you!

    http://wordpress.org/extend/plugins/hungryfeed/

  2. Jason
    Member
    Plugin Author

    Posted 2 years ago #

    there isn't a solution from within HungryFEED at the moment, I had not see that request before.

    one thing you can do is use CSS to truncate the text. on the HTML element that holds the title field, give it the class delcaration "truncate" then add the following CSS class definition:

    .truncate {
         overflow: hidden;
         text-overflow: ellipsis;
         white-space: nowrap;
    }
  3. HFman
    Member
    Posted 2 years ago #

    Hi,
    CSS is what i ended up using.
    Thanks

  4. zfirst
    Member
    Posted 1 year ago #

    For reasons specific to my site, the RSS fix doesn't work. Any chance you could implement a title truncation parameter in the same manner as the description truncation parameter? I've tried a variety of non-CSS workarounds including all manner of approaches within Yahoo Pipes, but can't get any of them to give me exactly what I need (the title truncated to an arbitrary character length and followed by an ellipsis, unless the title is already that length or shorter, in which case it doesn't get an ellipsis appended).

  5. Jason
    Member
    Plugin Author

    Posted 1 year ago #

    I'll add that to the list of features. I'm hoping to get to some updates soon once I get out from being buried with work! In the meantime, you could hard-code that in by updating hungryfeed.php around line 254 this line:

    $title = $item->get_title();

    just below that you could add a line to truncate the title, as a simple example:

    if (strlen($title) > 25) $title = substr($title,0,25) . "...";

  6. zfirst
    Member
    Posted 1 year ago #

    Thanks for the quick fix! Using your code in WP 3.4.1, I got an "unexpected ';'" error. I tweaked it a bit as follows and everything works great (in addition to fixing the syntax, I upped the string length to 42 characters and replaced the three periods with an HTML ellipsis character):

    if (strlen($title) > 42) $title = substr($title,0,42) . '…';

  7. zfirst
    Member
    Posted 1 year ago #

    Quick tip for others who might try this solution: I just realized that the php code error I was getting was due to my having copied the code from the email version of verysimple's forum reply that WordPress.org sent me. If I'd started with the code as he posted it here in the forum, I believe I would've been good to go.

  8. Jason
    Member
    Plugin Author

    Posted 1 year ago #

    ah cool, glad that you got it sorted out.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags