WordPress.org

Support

Support » Plugins and Hacks » HungryFEED » [Resolved] [Plugin: HungryFEED] Truncate Title

[Resolved] [Plugin: HungryFEED] Truncate Title

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Jason

    @verysimple

    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;
    }

    Hi,
    CSS is what i ended up using.
    Thanks

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

    Plugin Author Jason

    @verysimple

    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) . "...";

    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) . '…';

    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.

    Plugin Author Jason

    @verysimple

    ah cool, glad that you got it sorted out.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Resolved] [Plugin: HungryFEED] Truncate Title’ is closed to new replies.
Skip to toolbar