WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've tried to follow the example for Testing for paginated Pages but i don't know why it isn't working. i put it in the single.php file for post detection. i don't know why the page_test is broken. example code here:


    <div id="content" class="narrowcolumn" role="main">
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
        <div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
            <h2><?php the_title(); ?></h2>
            <div style="margin-top:5px">
<div style="padding:5px; float:left; margin-right:50px;"><fb:share-button href="<?php the_permalink(); ?>" class="url" type="button_count"></fb:share-button></div>

        $page_test = $wp_query->get( 'paged' );
        if ( ! $page_test || $page_test < 2 ) {

            something here...

            <?php } else { ?>

            another here...

            <?php } ?>
share|improve this question
global $wp_query; – edelwater Mar 20 '11 at 23:13

You need to either add global $wp_query;

global $wp_query;
$page_test = $wp_query->get( 'paged' );

or use get_query_var();

$page_test = (get_query_var('paged')) ? get_query_var('paged') : 1;
share|improve this answer
Just updated Asafs answer... the true on false is a little missleading. – kaiser Mar 22 '11 at 5:01
up vote 1 down vote accepted

the above solution i tried already.

Never mind, i solved it, even i don't know why. if some body knows...: this:

// not working
    $paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : false;
    if ( $paged === false ) {

didn't worked, but this:

// works
    $paged = get_query_var( 'page' ) ? get_query_var( 'page' ) : false;
    if ( $paged === false ) {

did work. the difference is "page" instead of "paged". i don't know why everywhere i looked i've found the code with "paged" and it didn't worked (even it the conditional tags page in the codex!), but here, in a simple topic i found it.

nevertheless, it is solved.

share|improve this answer
ehm yea. both codes are exactly the same... – kaiser Mar 21 '11 at 21:57
sorry, fixed the difference between them – Asaf Chertkoff Mar 22 '11 at 3:35
n/p. I updated the codex with your answer. I'm sure i also ran into this once. I also updated your answer, because the "true" on false would be missleading. I hope you don't mind. – kaiser Mar 22 '11 at 4:57
you're more then welcome. for the greater good ;-) – Asaf Chertkoff Mar 23 '11 at 8:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.