Home › Forums › MapPress Support › HTML in info box/excerpt
- This topic has 3 replies, 1 voice, and was last updated 2 years, 1 month ago by
Chris.
-
AuthorPosts
-
November 19, 2020 at 9:17 am #18748
I can’t get the HTML to work in the infobox (ie, I have <br> and tags in my excerpt). I’m using Formidable Forms and have a field mapped to the excerpt. I am pretty sure this was working in a previous version.
November 19, 2020 at 9:22 am #18749Hi,
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);
November 24, 2020 at 9:37 am #18762Thanks 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?
November 24, 2020 at 9:52 am #18763Sorry, 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.
December 22, 2020 at 11:16 am #18816Hi Chris,
I used the new filter to get the HTML to show, however my shortcode are being executed. (I realized they were not executed anyway with the filter returning $excerpt).
Is there a way to have the excerpt with HTML and shortcodes being executed?
December 22, 2020 at 11:18 am #18817Hi,
I’m not clear on whether you do or do not want the shortcodes, but if you don’t want them, you can call strip_shortcodes() on the text. If you do want them executed, use do_shortcode() on it.
I hope that’s enough info… Also, please be aware that not all shortcodes will work in a popup. For example, some need to load their own JavaScripts, and they won’t realized it’s necessary if the shortcode is embedded in a popup.
December 23, 2020 at 8:16 am #18818Thanks! I tried do_shortcode with a very basic shortcode and it did work, so must be my shortcodes.
For anyone else that might be reading this ticket – this is the code to put in your functions.php to return your excerpt with the html in your poi:
function rawpoi($excerpt, $raw) {
return $raw;
}
add_filter(‘mappress_poi_excerpt’, ‘rawpoi’, 10, 2); -
AuthorPosts
- You must be logged in to reply to this topic.