Quantcast
Channel: WPRecipes
Viewing all articles
Browse latest Browse all 121

How to detect a comments page on your WordPress blog

$
0
0

Simply put the following code anywhere on your theme files. If you're on a comment page, the conditional statement will return true, so any code within brackets will be executed.

$cpage = get_query_var( 'cpage' );
if ( is_singular() && $cpage > 0 ){
    // Your code here
}

This code works on posts, pages, attachments as well as all custom post_types.

Thanks to Daniel Roch for the cool tip!


Viewing all articles
Browse latest Browse all 121