1 に答える
1
WordPress には function はありませんが、the_subtitle
通常、 で始まるすべての関数は値を出力し、 で始まる関数はthe_*
値をget_the_*
返します。
をフィルタリングしている関数内で呼び出しているthe_title
(はずである) ため、コードは無限ループに入りました。コールバック内のフィルターを削除および追加することで修正できますが、タイトルは既に利用可能であるため、それは必要ありません。get_the_title
the_title
また、$post
定義せずに使用しており、必要ありません。投稿 ID も既に利用可能です。
the_subtitle()
最後に、この関数を から取得した値と混同していると思います$subtitle=get_post_meta()
。
add_filter( 'the_title', 'new_title', 10, 2 );
function new_title( $title, $id )
{
# http://codex.wordpress.org/Conditional_Tags
if( !is_page_template( 'about.php' ) )
return $title;
if( 'page' == get_post_type( $id ) )
$subtitle = get_post_meta( $id, 'html5blank_webo_subtitle', true );
if ( $subtitle ) :
$title = '<div class="page-title">'
. $title
. '</div><h1 class="subtitle">'
. $subtitle
. '</h1>';
else :
$title = '<h1 class="page-title">' . $title . '</h1>';
endif;
return $title;
}
于 2013-09-27T00:17:05.780 に答える