2016-07-22 24 views
1

我試圖創建一個額外的簡碼內的格式顯示the_content返回the_content()與簡碼

function custom_recipe_content($atts){     
    if (! is_singular('recipe')) { 
     return; 
    }    
    return the_content();   
} 
add_shortcode('recipe_content', 'custom_recipe_content'); 

當我加入WP文本構件內[recipe_content]簡碼,它的小部件,而不是上面添加在小部件內部。

任何幫助,非常感謝。

回答

0

,請返回

apply_filters('the_content',the_content()); 

這將實現內容的內容。

+0

即使不工作。內容正在返回就好。我認爲問題在於使用文本小部件「echo」中的代碼。 – kiarashi

1

找到了解決辦法,這要歸功於TRS:

$content = apply_filters('the_content', get_the_content(), get_the_ID()); 

    return $content;