1

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 } ?>
  • 2
    global $wp_query; – edelwater Mar 20 '11 at 23:13
3

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;
  • Just updated Asafs answer... the true on false is a little missleading. – kaiser Mar 22 '11 at 5:01
1

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.

  • 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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