1

ページまたは投稿がパスワードで保護されている場合に使用されるテンプレートページを編集しようとしています。私はそれを見つけるのにあまり運がないようです。

どこにあるか分かりますか?

4

2 に答える 2

4

パスワードで保護されたページ/投稿が通常のページ/投稿と同じテンプレートを使用していることを理解しています。「私の投稿はパスワードで保護されています。パスワードを入力してください:」という標準メッセージを変更する場合は、次のコードスニペットをテーマのfunction.phpファイルに追加してみてください(テキストを変更して希望どおりに読み上げてください)。

function fb_the_password_form() {
    global $post;

    $label = 'pwbox-'.(empty($post->ID) ? rand() : $post->ID);
    $output = '<form action="' . get_option('siteurl') . '/wp-login.php?action=postpass" method="post">
    <p>' . __("My post is password protected. Please ask me for a password:") . '</p>
    <p><label for="' . $label . '">' . __("Password") . ' <input name="post_password" id="' . $label . '" type="password" size="20" /></label> <input type="submit" name="Submit" value="' . esc_attr__("Submit") . '" /></p>
    </form>';

    return $output;
}
add_filter('the_password_form', 'fb_the_password_form');

これは、WPエンジニアによるパスワードページの文言の変更で見つかりました。

于 2010-02-14T07:54:08.393 に答える
1

21の子テーマでは、上記は機能しませんでした。代わりに、私はこのコードを使用しました(残念ながら、誰が書いたか思い出せません):

<?php
function my_password_form() {
    global $post;
    $label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
    $o = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" method="post">
    ' . __( "Some custom statement here.\nAnd a second line:\n" ) . '
    <label for="' . $label . '">' . __( "Password:" ) . ' </label><input name="post_password" id="' . $label . '" type="password" size="20" maxlength="20" /><input type="submit" name="Submit" value="' . esc_attr__( "Submit" ) . '" />
    </form><p style="font-size:18px;margin:0px; padding: 8px; background: lightblue; height: 40px; width: 400px; text-align: center;">Some other text here</p>
    ';
    return $o;
}
add_filter( 'the_password_form', 'my_password_form' );
?>
于 2014-11-29T13:35:18.780 に答える