The PHP function of calling comment template and looping output comment in WordPress, detailed wordpress_php Tutorial

Source: Internet
Author: User
Tags pings nginx server

The PHP function of invoking comment template and loop output comment in WordPress, detailed WordPress


Comments_template
The Comments_template function is a function that invokes a comment template, which is simple to use, as is an include file class function like Get_header (), which is used today.

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

Use

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

which

$file the default value of the file name that needs to be called:/comments.php
$separate _comments whether to separate comments without types Boolean default value: False
Speak more general, more deeply please look down

Working with instances

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

This way, you can display article comments based on your different article types.
Is it a bit similar to Get_template_part () in usage?
As for $separate_comments accurate meaning, I do not understand, but the official default theme has always been true, so I also follow up. Previously studied, it seems that the type referred to here is whether the meaning of the reply.

Wp_list_comments
wp_list_comments function is a loop output of the current article or page each comment function, in WordPress theme is used to output each comment, Save our manual convenience of suffering, but also the WordPress review function is very good modular.

wp_list_comments function in the theme with the Comments_template function can be used in conjunction with the WordPress review function independently, but also better to comment on the number of nested layers, the number of comments per page, comment style, etc. and so on control. So if you want to be a good subject, look at it.

Describe
English Original:

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

My understanding:
Displays all comments for an article and page with an overall set of parameters.

Usage

<?php   wp_list_comments ($args);?>

Parameter usage

<?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 Avatar Size default:32
$style comments The container label can be ' div ', ' ol ', or ' ul ', the default value is ' UL ', if not, then you need to write clearly as follows.

<?php wp_list_comments (Array (' style ' = ' div '));?>

Or

 
  
  
    <?php wp_list_comments (Array (' style ' = ' ol ');?>

The

$type shows what comments, 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 does not explain the default value: ' Reply '
$login The text value of the _text login button, which is less used to interpret 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 the loop, I do not test, please explore by yourself. The
$reverse _top_level boolean value, and if set this argument is true, the latest comment is displayed first, followed by the background settings. The
$reverse _children boolean value, and if set this argument is true, the last comment that has a comment is displayed, followed by the background settings.
Instance
Here is the official default theme Twentyeleven in the comments show demo,
specific other parameters please refer to the above introduction of self-demonstration exploration.

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

Articles you may be interested in:

    • Analysis of correlation function used in WordPress development for caption Display
    • Analysis of PHP function usage in debugging thumbnail in WordPress
    • configuration resolves the WordPress path in the Nginx server does not automatically add a slash problem
    • The PHP function used in WordPress to get the search form is parsed
    • Use the Wp_count_posts function in WordPress to count the number of articles
    • A detailed description of the use of classification function wp_list_categories in WordPress
    • WordPress restricts non-admin users to comment only once after the article
    • Detailed PHP functions for creating and adding filters in WordPress
    • A detailed description of the use of Wp_title () functions in WordPress development

http://www.bkjia.com/PHPjc/1088779.html www.bkjia.com true http://www.bkjia.com/PHPjc/1088779.html techarticle in the WordPress call comment template and the loop output comment php function, detailed wordpress comments_template comments_template function is a call comment template function, use very ...

  • 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.