[resolved] get_query_var cpage doesn't seem to be working? (9 posts)

  1. richarduk
    Posted 4 years ago #

    Changing the number of comments to display per page doesn't change the number echoed when using the following in comments.php

    <?php echo '<h1>' . get_query_var('cpage') . '</h1>' ;?>

    I was hoping to use get_query_var to turn on or off comment navigation links on pages of comments.

  2. richarduk
    Posted 4 years ago #

    I'll use the 20/11 theme for that.

    if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) :

  3. What theme are you using?

  4. richarduk
    Posted 4 years ago #

    My own :-)

    The relevant bit of code was this:

    <?php  if ( get_option( 'page_comments' ) && ( get_query_var( 'cpage' ) > 1 || get_query_var( 'cpage' ) < get_comment_pages_count( ) ) ) { ?>
    <div class="comment-navigation">
    <p class="comment-navigation comment-floatright"> <?php next_comments_link( 'Newer Comments' ) ?></p>
    <p class="comment-navigation comment-floatleft"><?php previous_comments_link( 'Older Comments' ) ?> </p>
    </div><!--Close comment-navigation-->
     <?php } ?>

    Obviously I played around and deleted this and removed that and narrowed it down to the code in the original post

  5. get_query_var( 'cpage' )

    Where is that being defined?

  6. richarduk
    Posted 4 years ago #


    Do I need to set some sort of global or something?

  7. I'm not sure :( I would have to defer to a theme goddess.

    Where did Esmi go...

  8. richarduk
    Posted 4 years ago #

    It's something to do with my theme. Tested <?php echo '<h1>' . get_query_var('cpage') . '</h1>' ;?> in twenty eleven this morning and it worked fine.

    Sorry, should have checked that first.

  9. richarduk
    Posted 4 years ago #


    Tested using:

    <?php echo '<h1>get_query_var(cpage)' . get_query_var('cpage') . '</h1>' ;?>
    <?php echo '<h1> get_comment_pages_count ' .  get_comment_pages_count() . '</h1>' ;?>
    <?php echo '<h1>get_option(page_comments) '. get_option('page_comments') . '</h1>' ;?>

    get_query_var(cpage) and get_comment_pages_count() don't work if they come after the pings callback, when comments and pings are separated i.e. comments first, then pings

    <?php wp_list_comments( 'type=pings&callback=my_theme_list_pings&style=div' ); ?>

    Therefore paged navigation for comments can't come at the bottom of the page but must come after the comments but before the pings.

    It used to work; somewhere in the last upgrade or two it stopped working.

Topic Closed

This topic has been closed to new replies.

About this Topic