Detailed comments in WordPress call comment template and circular output comment php function _php tips

Source: Internet
Author: User
Tags comments pings

Comments_template
the Comments_template function is a function that invokes the comment template, which is simple to use, and is an include file class function, like Get_header (), for today's use.

Describe
As already mentioned, it is a function that invokes the comment template.

Use

 <?php comments_template ($file, $separate _comments);?>

which

$file filename Default value to call:/comments.php
$separate _comments whether to separate comments of type without comment Boolean default value: False
Speak more general, deeper level please look down

Working with instances

 <?php comments_template (Get_post_format (). ' -comment.php ', true);?>

This way, you can display the article comments according to your different article types.
Is it a bit like get_template_part () in usage?
As for the exact meaning of $separate_comments, I didn't get it, but the official default theme was always true so I followed up. Previously studied once, seemingly here refers to the type is whether or not the meaning of the reply.

Wp_list_comments
wp_list_comments function is a circular output of the current article or page of each comment function, in the WordPress theme is mainly used to output every comment, save us the pain of manual convenience, but also WordPress's comments function very well in the modular.

wp_list_comments function in the theme with the Comments_template function of the joint use can be very good to WordPress's comments function independently, but also better on the comments nested layer, each page to show the number of comments, comments, etc., such as the style of control. So if you want to do a good job on the subject, look at it.

Describe
English Original:

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

My understanding:
Use a whole set of parameters to display all comments for an article, page.

Usage

<?php
   wp_list_comments ($args); 
? >

Parameter use

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

$walker Custom Style class name
$avatar _size Head Size default:32
$style Comment Container label can be ' div ', ' ol ', or ' ul ', default is ' UL ', if not, then you need to write as clearly as follows.

<div class= "Commentlist" ><?php wp_list_comments (Array (' style ' => ' div '));?></div>

Or

<ol class= "Commentlist" ><?php wp_list_comments (Array (' style ' => ' ol '));?></ol>

What comments $type display, parameters can be ' all ', ' comment ', ' trackback ', ' pingback ', ' pings '. ' Pings ' includes ' trackback ' and ' Pingback '.
Default: ' All '
$reply the text value of the _text Reply button, which is less a text value that does not interpret the default value: ' Reply '
$login _text login button, which is less used without interpreting the default value: ' Log in to reply '
$callback comment shows the callback function, that is, the function name that displays the comment topic
$end-callback should be the callback function after the end of loop, I have not measured, please explore yourself.
$reverse _top_level boolean value, if this argument is true, the latest comment is displayed first, and the following comments are displayed in the background settings.
$reverse _children boolean value, if this argument is true, the latest comment with a child comment is displayed, and the following comments are displayed in the background settings.
Instance
This is the official default theme Twentyeleven in the comments display demo,
specific other parameters please refer to the above introduction of their own demo explore.

<ol class= "Commentlist" >
<?php/
 * Loop through and list the comments. Tell Wp_list_comments ()
 * to use twentyeleven_comment () to format the comments.
 * If you are want to overload this in a child theme then your can
 * define twentyeleven_comment () and that'll be used INS Tead.
 * Twentyeleven_comment () in twentyeleven/functions.php for more.
 /wp_list_comments (Array (' Callback ' => ' twentyeleven_comment '));
The Twentyeleven_comment function is defined in the theme file "twentyeleven/functions.php".
?>
</ol>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.