HTML in info box/excerpt

Home Forums MapPress Support HTML in info box/excerpt

Tagged: ,

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #18748
    jreyes
    Participant
    #18749
    Chris
    Keymaster

    Hi,

    I don’t think it’s changed, but MapPress calls the function wp_trim_words() to limit excerpts to 55 characters.  That function also strips out any HTML tags and characters.

    The wp_trim_words() function is also called in normal theme functions like the_excerpt().  It’s an involved process, this article has an explanation:

    https://www.satollo.net/how-the_excerpt-function-works-in-wordpress

    Anyway, if you want to force tags through, there’s a filter that allows you to determine what wp_trim_words() should return.  The filter’s last argument is the orginal text, so if you add the following to your theme’s functions.php file, it should return it unaltered.

    Note that this will affect all excerpts, including elsewhere in the blog.

    function mytrimwords($text, $num_words, $more, $original_text) {
    return $original_text;
    }
    add_filter('wp_trim_words', 'mytrimwords', 10,4);
    
    #18762
    jreyes
    Participant

    Thanks for your quick reply! I don’t think I quite have my head around this. Yes – the code you posted works perfect for all excerpts. I’m not quite seeing how to address this for only the map custom post type.

    I have tried modifying the ‘get_the_excerpt’ filter, but it appress the mappress excerpt is not responding to that filter.

    I found in mappress_poi where the function get_post_excerpt is using wp_trim_words.

    Do I have to filter that result somehow?

    #18763
    Chris
    Keymaster

    Sorry, I didn’t realize the change should be only for maps.

    It’s possible to do this using filter ‘mappress_post_query’ instead. That filter lets you modify the results of a mashup query before it’s displayed.

    However, I think it would make more sense to just add a new filter ‘mappress_poi_excerpt’ specifically for excerpts, since this issue comes up frequently – many themes & plugins modify the standard functionality.

    Could you use the contact form to send a login to your blog? I’d like to add the new ‘mappress_poi_excerpt’ filter directly to your plugin, and once it’s working for you, I’ll also include it in the next release.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.