WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] If is comment paged ? (4 posts)

  1. SimonJ
    Member
    Posted 4 years ago #

    Hi all!

    Ok, here is my question :

    I know the conditional tag "is paged"...

    I wonder if there is a similar condition for comment pages...

    Something like : if is comment paged

    I would like to display something if we are currently on a comment page

    domain.tld/permalink-to-post/comment-page-1/

    Am I clear ? :-)

    Thanks!

    S.

  2. Mark / t31os
    Moderator
    Posted 4 years ago #

    Example to output comment page number:
    echo get_query_var('cpage');

    If it doesn't return a value, then you can assume it's the first page..

    Can handle the var in the same way as paged... if you want to use it for something..

    Further example:

    $comment_paged = ( get_query_var('cpage') && get_query_var('cpage') > 1 ) ? get_query_var('cpage') : 1;
  3. SimonJ
    Member
    Posted 4 years ago #

    Nice nice nice...

    Here is what I did based on your suggestion :

    <?php
    $page_comment = get_query_var('cpage');
    if ($page_comment > 0) {
    echo 'comment page : '.$page_comment;
    }
    ?>

    For anyone searching this forum in the future, I was looking for a solution to add the page comment number in the <title> tag in my header, to avoid "double <title> tags" in search engine indexation...

    Another resolved issue! Thanks

    S.

  4. Mark / t31os
    Moderator
    Posted 4 years ago #

    You're welcome..

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.