Feature A Page Widget
[resolved] Possible to include html code in experpt? (6 posts)

  1. umchal
    Posted 2 years ago #


    I'd like to include an icon in the excerpt text besides the featured image. I tried including HTML code in the excerpt but it is just literally translated so it's not possible?


  2. Mark Root-Wiley
    Plugin Author

    Posted 2 years ago #

    Hi @umchal,

    I should make this clearer on the plugin page. Because the excerpt may be used in other places, I didn't want to just enable HTML in the widget text and risk having it not work elsewhere.

    Hence, I've added support in version 1.1.0 for the Rich Text Excerpts plugin. If you install that, my plugin will automatically support HTML and you'll get the WYSIWYG editor in all your excerpts. (Of course, if you don't like that, you can always flip over to "text" mode of the editor.)

    Make sure to mark this thread as resolved if this answers your question.

  3. umchal
    Posted 2 years ago #

    Thanks for the reply, Mark.

    I just tried the plugin and indeed the rich text editor appeared in the excerpt field but the result was the same. The widget shows the literal HTML code. I'm using WordPress 3.5.

    And for the first time when I tried to save the options of Rich Text Excerpts via the admin page, it threw these errors if that is relevant. It does not throw the errors after that any more.

    Warning: trim() expects parameter 1 to be string, array given in .../wp-content/plugins/rich-text-excerpts/rich-text-excerpts.php on line 339
    Warning: trim() expects parameter 1 to be string, array given in .../wp-content/plugins/rich-text-excerpts/rich-text-excerpts.php on line 344
    Warning: Cannot modify header information - headers already sent by (output started at .../wp-content/plugins/rich-text-excerpts/rich-text-excerpts.php:339) in .../wp-includes/pluggable.php on line 876
  4. Mark Root-Wiley
    Plugin Author

    Posted 2 years ago #

    Well bummer. Sorry to hear that. I had tested this combination just before the 3.5 release on one of the release candidates, but it looks like I missed something. I'll try to figure out what's going on and push out an update soon if I figure out what's going on.

    It also sounds like that plugin is conflicting with something in your site. I'm not seeing that error. If you want to resolve that issue, you'd probably need to open a thread on that plugin's forum. I've emailed the plugin dev in the past, so I'll try to bump him too.

    In the mean time, if the icon you want is at the beginning or end of the text and is purely decorative, you could do a straight CSS implementation with something like this (the values are off but that should get you started):

    .fpw-excerpt:before {
        width: 1em;
        height: 1em;
        display: inline-block;
        content: ' ';
        background: url(path/to/an/imagefile.gif) left center no-repeat;

    Alternately, if you know how, you could filter the excerpt yourself to replace some string with an icon. There are three filters in the plugin, one of which is fpw_excerpt.

  5. umchal
    Posted 2 years ago #

    Thanks for the great response. I'm looking forward to the update.

    I just briefly looked into the code in fpw_widget.class.php and changed the lines around #162,

    if( class_exists( 'RichTextExcerpts' ) )
    	$excerpt = wp_kses_decode_entities( $excerpt );


    $excerpt = wp_kses_decode_entities( $excerpt );
    $excerpt = htmlspecialchars_decode($excerpt);

    and it worked.

    So I'd like to suggest a feature to implement an option which allows to enforce HTML code (perform htmlspecialchars_decode() internally). Maybe a check box in the widget would be sufficient I guess.

  6. Mark Root-Wiley
    Plugin Author

    Posted 2 years ago #

    Hi @umchal.

    Sorry I missed your edit here. I just pushed the 1.2.0 release of the plugin out and it includes a fix for this issue.

    It still requires the Rich Text Excerpts plugin to be activated to work, though. If you want to hack it so that it's always turned on, you'd just need to remove the conditional around the lines you referenced above.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Feature A Page Widget
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.