Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




get_comment_pages_count [ WordPress Function ]

get_comment_pages_count ( $comments = null, $per_page = null, $threaded = null )
Parameters:
  • (array) $comments Optional array of comment objects. Defaults to $wp_query->comments
  • (int) $per_page Optional comments per page.
  • (boolean) $threaded Optional control over flat or threaded comments.
Uses:
Returns:
  • (int) Number of comment pages.
Defined at:



Calculate the total number of comment pages.

Source


<?php
function get_comment_pages_count$comments null$per_page null$threaded null ) {
    global 
$wp_query;

    if ( 
null === $comments && null === $per_page && null === $threaded && !empty($wp_query->max_num_comment_pages) )
        return 
$wp_query->max_num_comment_pages;

    if ( !
$comments || !is_array($comments) )
        
$comments $wp_query->comments;

    if ( empty(
$comments) )
        return 
0;

    if ( !isset(
$per_page) )
        
$per_page = (int) get_query_var('comments_per_page');
    if ( 
=== $per_page )
        
$per_page = (int) get_option('comments_per_page');
    if ( 
=== $per_page )
        return 
1;

    if ( !isset(
$threaded) )
        
$threaded get_option('thread_comments');

    if ( 
$threaded ) {
        
$walker = new Walker_Comment;
        
$count ceil$walker->get_number_of_root_elements$comments ) / $per_page );
    } else {
        
$count ceilcount$comments ) / $per_page );
    }

    return 
$count;
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

Kullanýcý Tartýþmalarý [ wordpress.org ]

- Bulunamadý -

Yeni bir konu yaz ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics