2012-07-01 71 views
0

我想用在WordPress the_content後添加my_custom_function使用WordPress的the_content的add_filter後插件內容()

add_filter ('the_content', 'my_custom_function'); 
add_action ('the_content', 'my_custom_function'); // I tried both 

my_custom_function功能是這樣

function my_custom_function($content) { 
    if(is_single()) { 
     $content .= "this is custom function content"; 
     $content .= my_another_custom_function(); 
     $content .= "this is custom function content"; 
    } 

return $content; 
} 

我的問題是這樣的代碼追加my_another_custom_function()the_content但我想的內容。

代碼$content .= "this is custom function content";給出的其他2線是用於測試和這些後the_content

出現有人可以給我關於如何解決它,我做錯了任何想法...

回答

1

最可能的原因是my_another_custom_function()回聲輸出,而不僅僅是返回它。

+0

我another_custom_function是這樣 '函數m_a_c_f { \t \t回波 '

    '; \t \t foreach($ result as $ result){ \t \t \t echo'
  1. '; \t \t \t echo $ result-> title; \t \t \t echo'
  2. '; \t} \t \t echo'
'; }' 可以請你告訴我如何返回這不是回聲,我也必須在其他地方[手動]使用此功能。那我以後怎麼用呢? – Anuj

+0

我得到了它的感謝! – Anuj

相關問題