How to detect a comments page on your WordPress blog
Tento článek (nebo jeho část) je převzat z externího zdroje. Je tedy slušností jej uvést včetně případného autora.
On WordPress dashboard, there’s an option to divide comments lists in sub pages. Unfortunately, there’s no built-in conditional tag to know if you’re currently on a comment page. So let’s built one!
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.
1 2 3 4 |
$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.
Napsat komentář