1

我正在尝试自定义 Word 新闻模板并且遇到了一些麻烦。该页面是http://rexonmedia.com/?page_id=113,每个部分下都有描述,描述中的所有文本都是纯文本(Actionscript,访问站点...)。我希望文本被格式化或具有链接,如源 (http://rexonmedia.com/?portfolio=audiomaya) 和超链接。

我发现这里的罪魁祸首是“strip_tags”标签。它用于两个不同的地方。我尝试了几个场景,但没有奏效。请帮忙

   public function customFormat($content,$strip_tags = false,$shortcode=true){
   $content =   stripslashes($content);
   if($shortcode)
   $content = do_shortcode( shortcode_unautop( $content ) ); 
   $content = preg_replace('#^<\/p>|^<br\s?\/?>|<p>$|<p>\s*(&nbsp;)?\s*<\/p>#', '', $content);

   if($strip_tags)
     $content = strip_tags($content,"<hades>,<tabend>");

   return $content;

    }   

<?php  
global $more;    // Declare global $more (before the loop).
    $more = 1;
$content = get_the_content('');
$content = apply_filters('the_content', $content);
    $content = str_replace(']]>', ']]&gt;', $content);
$this->shortenContent( $content_limit ,  strip_tags( $content  ) ); 
?>
4

1 回答 1

1

为 strip_tags 提供允许的标签。第一个代码块中的行将更改为:

$content = strip_tags($content,"<strong><a>");

第二个代码块中的行将更改为:

$this->shortenContent( $content_limit ,  strip_tags( $content, "<strong><a>" ) ); 

顺便说一句,如果未提供 $strip_tags 函数,该函数在函数定义中将其定义为 false。检查那个!

public function customFormat($content,$strip_tags = false,$shortcode=true){
于 2012-06-21T18:27:36.363 回答