I'm trying to create a custom Facebook share button on a WordPress theme
<a title="Facebook This" href="http://www.facebook.com/sharer.php?s=100&p[title]=MY%20TITLE%20-%20<?php the_title(); ?>&p[summary]=<?php the_content(); ?>&p[url]=<?php the_permalink(); ?>&p[images][0]=<?php bloginfo('template_url'); ?>/images/logo.png" target="_blank">Facebook This</a>
I have everything working splendidly except that Facebook insists on displaying the HTML characters in the description:
<h3>Intro</h3><p>it shows all the tags here and it won't stop!!!</p>...
It does this with the_excerpt() as well.
Does anyone know a quick way to remove the html tags for this?
使用Strip标签,详细信息请参见: http ://php.net/manual/zh/function.strip-tags.php
strip_tags(get_the_excerpt());
塞弗丁·萨克(Saifuddin Sarker)的答案是一个很好的方法,另一种方法是:
Escape WordPress's HTML characters in the_content(); is use:
ob_start();
the_content();
$old_content = ob_get_clean();
$new_content = strip_tags($old_content);
echo $new_content;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.