我只想得到这篇文章的摘录。
目前,我正在使用get_the_excerpt(), 但它返回以下格式的字符串:
<p>LOREM IPSUM!… <a href="http://localhost/post/3" class="read-more">Read More</a></p>
 我需要得到
LOREM IPSUM (真实摘录文本)仅限,不带包装
<p> 标签或
<a> 链接内部。
有没有办法使用WordPress和PHP函数获取这个字符串?
非常感谢。
 
                    最合适的回答,由SO网友:Drupalizeme 整理而成
                    你可以试试这个:
$string =\'<p>LOREM IPSUM!… <a href="http://localhost/post/3" class="read-more">Read More</a></p>\';
$string = preg_replace(\'/<a[^>]*(.*?)<\\/a>/s\', \'\', $string);
echo wp_strip_all_tags($string);
 //返回LOREM IPSUM!…