2011-11-10 8 views
0

現在、私はWordpress用のギャラリープラグインを開発しています。ユーザーにギャラリーの位置を選択するオプションを提供したいと思います(the_contentの前後)。the_content(wordpress)の前にコードを挿入する

現在、私はこのようなthe_contentに引っ掛けることで、コンテンツの後にそれを置くことに成功した:

function add_post_content($content) { 

    if ('gallery' == get_post_type() && is_single()) { 

     $content .= gallery_frontend(); 
     $content .= gallery_map_display(); 

    } 

    if ('gallery' == get_post_type() && is_archive()) { 

     // archive functions here  

    } 

    return $content; 

} 

add_filter('the_content', 'add_post_content'); 

は、それが後の代わりにthe_contentの前に表示するように取得する方法はありますか?

答えて

1

他の方向に連結するだけでいいですか?

$content = gallery_frontend() . gallery_map_display() . $content; 

私はあなたの関数が何をしているのか分かりませんが、文字列データを返すだけであれば問題ありません。

http://php.net/manual/en/language.operators.string.php

+0

ありがとうm8、魅力的な作品です!ときにはそれはちょうど奇妙です:それは簡単にできる:-) –

+0

偉大なので、あなたの質問に答えますか? –

+0

ええ、確かに:)ありがとう! –

関連する問題