PDA

  • WordPressをスマートフォンに対応させるプラグイン「Wordpress PDA & iPhone」はスマートフォンからの閲覧時にコメントの表示や書き込みができない。
    本格的なスマートフォンでの運用を考えた場合、コメントも重要。
    一般的な方法としては、テンプレートに

    <?php comments_template(); ?>

    <?php comments_template('comments.php'); ?>

    を追加するのだが、
    上記の場合、呼び出されるcomments.phpは同階層のcomments.phpではなく

    /wp-includes/theme-compat/comments.php

    が呼び出されてしまう。

    comments.phpの中身をカスタマイズしないのであればそれでも構わないが、例えばコメントフォームにある「ウェブサイト」を消したい場合やスタイルに手を入れたい場合、このファイルを修正してしまうと、バージョンアップの度に修正しなくてはならなくなる。

    同階層のcomments.phpを呼び出す場合は、

    <?php comments_template('/comments.php'); ?>

    とファイル名の前に「/」を入れる。

    なお、
    元に入っているcomments.phpの中身は

    <?php if ( have_comments() ) : ?>
    <?php endif; ?>

    だけなので、

    /wp-includes/theme-compat/comments.php
    のファイルをコピーして修正して、置き換えればいい。

    具体的な、コメントを呼び出すための修正は以下の通り

    page.php

    ファイルの場所は
    /wp-content/plugins/wp-pda/jqmobile-theme/page.php

    ファイルを開き

    <div><?php the_content(); ?></div>
    <p>
    <small>
    <?php echo sprintf(__('This entry was posted on %1$s at %2$s and is filled under:','pda-theme'), the_date(__('l, F jS, Y','pda-theme'), '', '', FALSE),get_the_time()) . " "; the_category(', ');?>
    </small>
    </p>
    </div>
    <?php endwhile; else: ?>

    の箇所に追加して

    <div><?php the_content(); ?></div>
    <p>
    <small>
    <?php echo sprintf(__('This entry was posted on %1$s at %2$s and is filled under:','pda-theme'), the_date(__('l, F jS, Y','pda-theme'), '', '', FALSE),get_the_time()) . " "; the_category(', ');?>
    </small>
    </p>
    <?php comments_template('/comments.php'); ?>
    </div>
    <?php endwhile; else: ?>
    
    </div><!-- /content -->

    となるようにする。

    ————————————————————————————

    single.php

    ファイルの場所は
    /wp-content/plugins/wp-pda/jqmobile-theme/single.php

    ファイルを開き

    <div><?php the_content(); ?></div>
    <p>
    <small>
    <?php echo sprintf(__('This entry was posted on %1$s at %2$s and is filled under:','pda-theme'), the_date(__('l, F jS, Y','pda-theme'), '', '', FALSE),get_the_time()) . " "; the_category(', ');?>
    </small>
    </p>

    の後ろに追加して

    <div><?php the_content(); ?></div>
    <p>
    <small>
    <?php echo sprintf(__('This entry was posted on %1$s at %2$s and is filled under:','pda-theme'), the_date(__('l, F jS, Y','pda-theme'), '', '', FALSE),get_the_time()) . " "; the_category(', ');?>
    </small>
    </p>
    <?php comments_template('/comments.php'); ?>

    となるようにする。