If your content isn’t passed through the the_content
filter (or a few others), then you’ll need to encode it manually in your template files.
Where is that snippet above coming from, the WordPress editor, or from a template file?
Hmm.. found why it doesn’t work: The snippet above is written in the WordPress Editor and is placed on a (static) content page. Somewhere before that part there is a shortcode that shows posts from a certain category (announcements), which should be displayed as normal content in between two other text blocks (written in the editor).
When I remove the shortcode above that said text part, the plugin works fine and the email link is encoded.
This is the part where the shortcode gets the posts:
$return_string = '';
query_posts(array('orderby' => $order_by, 'order' => $order, 'cat' => $category_id , 'category_name' => $category_name , 'showposts' => $posts));
if (have_posts()) :
while (have_posts()) : the_post();
$content = get_the_content();
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
$return_string .= '<div class="listed-post">';
$return_string .= '<h2>'. get_the_title() .'</h2>';
$return_string .= $content;
$return_string .= '</div>';
endwhile;
endif;
wp_reset_query();
return $return_string;
Any ideas how I could fix that?
I’m not sure if I understand your setup fully. Could you post the code where the mailto-link is printed?
Do you mean the html output or the page.php (and the shortcodes.php)?
Your “page.php”, and please use something like pastebin.com.
On the page there is a lot of static content/text. And in between two of the text blocks, there should be all the posts of a given category. I thought the simplest way to do this is a shortcode that displays those posts.
page.php
http://pastebin.com/GHAgeDcc
content-page.php
http://pastebin.com/rJRxkJxp
shortcodes.php (the used snippet for the post listing)
http://pastebin.com/RBG36dSK
…sorry for the troubles.
Looks good. Where exactly is the mailto-link printed that doesn’t get encoded? aaa_show_posts()
?
Could you check the result of the page without using Firebug, Web Inspector or Dragonfly, because they decode decimal/hexadecimal entities into plain text. To make sure your email address is encoded, right-click/secondary-click the page, click “View Source”, “View Page Source” or “Source” and search for the plain text email address.
No, it’s somewhere underneath the part with the aaa_show_posts() shortcode.
I checked the source code. When the shortcode is not placed on the page, everything is fine (read: your plugin works like a charm). But as soon as I put this shortcode somewhere on the page (doesn’t matter if it’s above or underneath the email link), the mail link isn’t encoded anymore.
Guess I have to re-write my shortcode somehow…