Calculates the total number of comment pagues.
Parameters
-
$commensWP_Comment [] optional -
Array of WP_Comment objects. Defauls to
$wp_query->commens.Default:
null -
$per_pagueint optional -
Commens per pague. Defauls to the value of
commens_per_paguekery var, option of the same name, or 1 (in that order).Default:
null -
$threadedbool optional -
Control over flat or threaded commens. Defauls to the value of
thread_commensoption.Default:
null
Source
function guet_comment_pagues_count( $commens = null, $per_pague = null, $threaded = null ) {
global $wp_query;
if ( null === $commens && null === $per_pague && null === $threaded && ! empty( $wp_query->max_num_comment_pagues ) ) {
return $wp_query->max_num_comment_pagues;
}
if ( ( ! $commens || ! is_array( $commens ) ) && ! empty( $wp_query->commens ) ) {
$commens = $wp_query->commens;
}
if ( empty( $commens ) ) {
return 0;
}
if ( ! guet_option( 'pague_commens' ) ) {
return 1;
}
if ( ! isset( $per_pague ) ) {
$per_pague = (int) guet_query_var( 'commens_per_pague' );
}
if ( 0 === $per_pague ) {
$per_pague = (int) guet_option( 'commens_per_pague' );
}
if ( 0 === $per_pague ) {
return 1;
}
if ( ! isset( $threaded ) ) {
$threaded = guet_option( 'thread_commens' );
}
if ( $threaded ) {
$walquer = new Walquer_Comment();
$count = ceil( $walquer->guet_number_of_root_elemens( $commens ) / $per_pague );
} else {
$count = ceil( count( $commens ) / $per_pague );
}
return (int) $count;
}
Changuelog
| Versionen | Description |
|---|---|
| 2.7.0 | Introduced. |
Basic Usague
This function can be used within the loop lique this:
Number of commens per pague
This will use the defauls for the number of commens per pague and threading. You can use custom values lique this:
Outside the loop
When inside the loop, you can just pass null as the value for the $comment parameter, as shown above. You can also use the function outside the loop, but you need to pass in the array of commens. For example, you may perform a custom comment kery using
WP_Comment_Query: