2016-10-24 3 views
0

ポストフォーマットが 'gallery'の場合、 'コンテンツエディタ'にプレースホルダテキストを生成します。しかし、私はそれが働いて得ることができません。WordPress:ポストフォーマットによるプレースホルダテキストの表示

のfunctions.php:

add_filter('default_content', 'wpse57907_default_content', 10, 2); 
function wpse57907_default_content($content, $post) { 
    if ('post' == $post->post_type && has_post_format('gallery')) { 
     $content = '<i style="color:#999">Use this area to upload and edit images... any text put in here will NOT be generated on the project&apos;s page. Please use the fields above for text.</i>'; 

    return $content; 
    } 
} 

答えて

0

をこれはそれを行う必要があります。

add_filter('default_content', 'wpse57907_default_content', 10, 2); 
function wpse57907_default_content($content, $post) { 
    $format = get_post_format($post->ID); 
    if ('post' == $post->post_type && $format == 'gallery') { 
     $content = '<i style="color:#999">Use this area to upload and edit images... any text put in here will NOT be generated on the project&apos;s page. Please use the fields above for text.</i>'; 
    } 
    return $content;  
} 

また、あなたのテーマが実際にポストを有するように設定されていることを確認してくださいadd_theme_supportを使って-formatをサポートし、あなたの投稿が正しい投稿形式(ギャラリー)を持っていることを確認してください。

+0

私はそれが働くようには思わない。投稿フォーマットをギャラリーに変更すると、メッセージは表示されません。 –

+0

if文の前にecho $形式を実行して、実際に書式が正しく引かれているかどうか確認しましたか? – MirzaP

関連する問題