wordpressのカスタマイズでh2見出しの前にページリンク【前の記事へ|次の記事へ】を表示させようと思っています。
get_template_part()で【前の記事へ|次の記事へ】を取得し$pageに代入したいのですがうまくいきません。
get_template_part()の関数は変数として代入しpreg_replace()内で展開するにはどのようにすればよろしいでしょうか。よろしくお願いします。
function paginate_h2($the_content) {
if (is_single()) {
$page = get_template_part( 'lib/templates/paginate' );
$h2 = '/<h2.*?>/i';/ if ( preg_match( $h2, $the_content, $h2s )) {//h2見出しが本文中にあるかどうかチェック $the_content = preg_replace($h2, $page.$h2s[0], $the_content, 1); }
}
return $the_content;
}
add_filter('the_content','paginate_h2');

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/09/22 05:15