Support » Fixing WordPress » get_query_var cpage doesn't seem to be working?

  • Resolved richarduk


    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.

Viewing 8 replies - 1 through 8 (of 8 total)
  • I’ll use the 20/11 theme for that.

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

    What theme are you using?

    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

    get_query_var( 'cpage' )

    Where is that being defined?


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

    I’m not sure 🙁 I would have to defer to a theme goddess.

    Where did Esmi go…

    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.


    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.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘get_query_var cpage doesn't seem to be working?’ is closed to new replies.