首先,我使用的是Wordpress> Avada Theme>和Fusion Core Plugin。從使用Fusion Builder的wordpress中剝離HTML和短代碼
我想要做的是將任何帖子的內容都刪除爲幾個字符。而且我幾乎所有的東西都用到了,使用Fusion Core插件發佈內容。
這是我的功能,應該得到摘錄和縮小它。
function get_my_excerpt_by_id($post_id, $length, $strip_html)
{
if(!$length)
$excerpt_length = 35;
else
$excerpt_length = $length;
if(!isset($strip_html) || $strip_html == true)
$strip_html = true;
$the_post = get_post($post_id); //Gets post ID
$the_excerpt = apply_filters('the_content',$the_post->post_content); //Gets post_content to be used as a basis for the excerpt
if($strip_html == true)
$the_excerpt = strip_tags(strip_shortcodes($the_excerpt)); //Strips tags and images
$words = explode(' ', $the_excerpt, $excerpt_length + 1);
if(count($words) > $excerpt_length) :
array_pop($words);
array_push($words, '…');
$the_excerpt = implode(' ', $words);
endif;
return $the_excerpt;
}
所以這就像一個魅力除非我正在使用融合的核心插件後類型之一beccause然後我得到這個
」 .fusion-全角-4 {填充左:0像素!重要; ...'
任何想法爲什麼它不剝離短碼和CSS和HTML?雖然看着它,也許它只是CSS?那是停留。謝謝!
編輯:: 所以它證明了它只是留下的CSS。所以現在我必須弄清楚如何刪除它們。一段時間後一切....
這實際上是現在strip_tags的工作原理。上面的標籤是可允許的標籤,所以這些標籤將被跳過。但是,謝謝你花時間去幫助我。 – Bardsworth
是否要從內容中刪除短代碼?你嘗試過preg_replace功能嗎? –
更改爲get_the_content時,我根本沒有返回任何內容。那裏有什麼不同? – Bardsworth