comments_template

FUNCTION wp-includes\comment-template.php (ligne 1381) github
Loads the comment template specified in $file. Will not display the comments template if not on single post or page, or if the post does not have comments. Uses the WordPress database object to query for the comments. The comments are passed through the {@see 'comments_array'} filter hook with the list of comments and the post ID respectively. The `$file` path is passed through a filter hook called {@see 'comments_template'}, which includes the template directory and $file combined. Tries the $filtered path first and if it fails it will require the default comment template from the default theme. If either does not exist, then the WordPress process will be halted. It is advised for that reason, that the default theme is not deleted. Will not try to get the comments if the post has none.

Paramètres

Entrée :
$file = '/comments.php', $separate_comments = false
Sortie :
@param string $file              Optional. The file to load. Default '/comments.php'.
@param bool   $separate_comments Optional. Whether to separate the comments by comment type.

Utilisation

// Utilisation de la fonction comments_template
$result = comments_template($file = '/comments.php', $separate_comments = false);

if ($result) {
    // Votre logique ici
}

Actualités

Chargement des actualités...