Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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:

<?php
get_header();
?>

    <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>

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

            something here...

            <?php } else { ?>

            another here...

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

2 Answers

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
add comment
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
add comment

Your Answer

 
discard

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.