2012-07-01 6 views
0

내가 사용하는 워드 프레스에 the_contentmy_custom_function를 추가하기 위해 노력하고있어워드 프레스는()

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는 { \t \t 에코 '

    '이 ' 함수 m_a_c_f 같다; \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

관련 문제