wp_list_comments

Sponsored Link

管理領域でセットされるものを含むいろいろなパラメータに基づく記事またはページのためにすべてのコメントを表示します。

Sponsored Link

Displays all comments for a post or Page based on a variety of parameters including ones set in the administration area.

参照:2.7へのプラグインとテーマの移行

See also: Migrating Plugins and Themes to 2.7

wp_list_commentsのテンプレートタグ使用方法

<?php wp_list_comments( $args ); ?> 

デフォルトの使い方

<?php $args = array(
    'walker'            => null,
    'max_depth'         => ,
    'style'             => 'ul',
    'callback'          => null,
    'end-callback'      => null,
    'type'              => 'all',
    'page'              => ,
    'per_page'          => ,
    'avatar_size'       => 32,
    'reverse_top_level' => null,
    'reverse_children'  =>  ); ?>

ax_depth, per_page, と reverse_top_levelは、管理画面設定のSettings_Discussion_SubPanelを通してより簡単にコントロールする事が出来ますが、テーマはそれらの設定をここで覆すことができます。

max_depth, per_page, and reverse_top_level can be more easily controlled through the Administration Panel Settings_Discussion_SubPanel but a theme can override those settings here.

wp_list_commentsのパラメーター

これは、拡大して/説明する必要があります。

This needs expanding / explaining.

avatar_size

(int)アバターのサイズは、ピクセル単位で表示される必要があります。デフォルト値:32。 http://gravatar.com /は、1と512の間のサイズをサポートしています。

(int) Size that the avatar should be shown as, in pixels. Default: 32. http://gravatar.com/ supports sizes between 1 and 512.

style

(string)’div’、’ol’、’ul’のいずれかは、順序付けられた、または順序付けられていないリストを、divを使用してコメントを表示することができます。デフォルトは’ul’。

<div class="commentlist"><?php wp_list_comments(array('style' => 'div')); ?></div>

または

<ol class="commentlist"><?php wp_list_comments(array('style' => 'ol')); ?></ol>

の明示して書かれなければならないタグを含んでいるので注意してください。

(string) Can be either ‘div’, ‘ol’, or ‘ul’, to display comments using divs, ordered, or unordered lists. Defaults to ‘ul’. Note that there are containing tags that must be written explicitly such as

<div class="commentlist"><?php wp_list_comments(array('style' => 'div')); ?></div>

or

<ol class="commentlist"><?php wp_list_comments(array('style' => 'ol')); ?></ol>

type

(string)コメントのタイプを表示します。’all’, ‘comment’, ‘trackback’, ‘pingback’, あるいは ‘pings’を指定できます。’pings’は、’trackback’ と’pingback’と一緒です。デフォルトは、’all’です。

(string) The type of comment(s) to display. Can be ‘all’, ‘comment’, ‘trackback’, ‘pingback’, or ‘pings’. ‘pings’ is ‘trackback’ and ‘pingback’ together. Default is ‘all’.

reply_text

(string)返信リンクとして、各コメントにテキストが表示されます。 (この関数の引数ではなく、get_comment_reply_link関数に渡されます。)デフォルトは’Reply’ です。

(string) Text to display in each comment as a reply link. (This isn’t an argument of this function but it gets passed to the get_comment_reply_link function.) Default is ‘Reply’.

login_text

(string)コメントにログインとユーザー登録しなければならない場合、各コメントにテキストが表示されます。(この関数の引数ではなく、get_comment_reply_link関数に渡されます。)デフォルトは’返信するためにログインする’です。

(string) Text to display in each comment if users must be registered and logged in to comment . (This isn’t an argument of this function but it gets passed to the get_comment_reply_link function.) Default is ‘Log in to Reply’.

callback

(string) カスタム関数の名前は、それぞれのコメントを表示するために使用する。デフォルトはnullになります。カスタム関数を作成して使用する事は、各コメントを表示するために、すべての内部のワードプレスの機能を無視して呼び出されます。HTMLレイアウトに極端な変更を表示するコメントをカスタマイズして使う事ができます。推奨されません。

(string) The name of a custom function to use to display each comment. Defaults to null. Using this will make your custom function get called to display each comment, bypassing all internal WordPress functionality in this respect. Use to customize comments display for extreme changes to the HTML layout. Not recommended.

reverse_top_level

(boolean)これをtrueに設定すると、最初の最近のコメントの順序に戻って表示されます。

(boolean) Setting this to true will display the most recent comment first then going back in order.

reverse_children

(boolean)これをtrueに設定することは、最初の1つ目のコメントと一緒に子(レベルのコメントを返信)が表示され、順番に戻ります。

(boolean) Setting this to true will display the children (reply level comments) with the most recent ones first, then going back in order.

デフォルトの使い方

コメントの順序付きリストが出力されます。スレッドまたはページングのようなものが有効になっている、または無効になってる事は、設定ディスカッションサブパネルを介して制御されます。

Outputs an ordered list of the comments. Things like threading or paging being enabled or disabled are controlled via the Settings Discussion SubPanel.

<ol class="commentlist">
<?php wp_list_comments(); ?>
</ol>

コメントをカスタムコメントのみ表示のみで表示する方法

コメントの外観を制御するためのカスタムコールバック関数を使用しているのと同時にコメント(pingbacks か trackbacksはない)だけを表示しています。返信のリンクが表示されない場合、max_depth=X parameterのパラメータを追加してもよいです。

Displays just comments (no pingbacks or trackbacks) while using a custom callback function to control the look of the comment. You may want to add an max_depth=X parameter, if the reply links are not appearing.

<ul class="commentlist">
<?php wp_list_comments('type=comment&amp;callback=mytheme_comment'); ?>
</ul>

あなたのテーマのfunctions.phpファイルにカスタムコールバック関数を定義する必要があります。次に例を示します:

You will need to define your custom callback function in your theme’s functions.php file. Here is an example:

function mytheme_comment($comment, $args, $depth) {
$GLOBALS[‘comment’] = $comment; ?>

  • id=”li-comment-“>
    ‘ ); ?>

    %s says:‘), get_comment_author_link()) ?>

    comment_approved == ‘0’) : ?>


  • 末尾に

    の不足に注意してください。WordPressは一度全ての子その他諸々をリストにしてもWordPress自身が追加するでしょう。

    Note the lack of a trailing

    . WordPress will add it itself once it’s done listing any children and whatnot.

    変更ログ

    Since: 2.7.0

    ソースファイル

    wp_list_comments()は、wp-includes/comment-template.php内に位置しています。

    wp_list_comments() is located in wp-includes/comment-template.php.

    関連テンプレートタグ

    comments_number, comments_link, comments_rss_link, comments_popup_script, comments_popup_link, comment_ID, comment_author, comment_author_IP, comment_author_email, comment_author_url, comment_author_email_link, comment_author_url_link, comment_author_link, comment_type, comment_text, comment_excerpt, comment_date, comment_time, comment_author_rss, comment_text_rss, permalink_comments_rss, wp_list_comments, comment_reply_link, cancel_comment_reply_link, comment_form_title, comment_id_fields, previous_comments_link, next_comments_link, paginate_comments_links

    wp_list_authors, wp_list_categories, wp_list_pages, wp_list_bookmarks, wp_list_comments, wp_get_archives, wp_page_menu, wp_dropdown_pages, wp_dropdown_categories, wp_dropdown_users

    Sponsored Link