WordPress.org

Support

Support » Plugins and Hacks » [Resolved] [Plugin: WP-PageNavi] Trying to fix "Warning: You forgot to set the 'paged' query var

[Resolved] [Plugin: WP-PageNavi] Trying to fix "Warning: You forgot to set the 'paged' query var

  • Hello,
    I am struggling with a peace of code which I can’t get to work in a page template.
    I am trying to get all the posts with tags with the same name as the page. That is working however but on the second page of posts the error “Warning: You forgot to set the ‘paged’ query var.” appears and I can’t get more then 2 pages of posts to work.
    While I am not a programmer I try to learn every day.
    So could someone please check the following peace of code and tell me what is wrong?

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts('tag='.basename(get_permalink()).'&post_status=publish,future&paged=$paged');?>

    Thanks for any help!

    http://wordpress.org/extend/plugins/wp-pagenavi/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author scribu

    @scribu

    The problem is that you use single quotes instead of double quotes, so ‘paged’ gets the literal value ‘$paged’ instead of the value of the variable.

    It’s a lot clearer if you pass an array directly:

    <?php
    query_posts( array(
      'tag' => basename(get_permalink()),
      'post_status' => 'publish,future',
      'paged' => get_query_var('paged')
    ) );
    ?>

    Thanks so much Scribu. It is all working like a charm now 🙂
    I will definitely buy PHP for Dummies or an equivalent to help me learn more about it.
    Again thanks for your kind help!

    Scribu .. help me please

    My English is not good so I turn to translate.google.com.br
    I have a problem and I can not solve.

    When doing a query using ‘post_status’ => ‘future’, shows all pages, but only navigates to page 2.

    posts per page
    http://actmob.com/template100/?cat=3

    all posts
    http://actmob.com/template100/?cat=7

    code:

    <?php
    				query_posts( array(
    				  'category' => basename(get_permalink()),
    				  'post_status' => 'publish,future',
    				  'paged' => get_query_var('paged')
    				) );
    
    				if(have_posts()): while(have_posts()): the_post();
    				?>
    
    				<h2><?php the_title(); ?></h2>
                    <p><?php the_time('d/m/Y H:i');?></p>
    				<hr />
    				<?php endwhile; else: endif; ?>
    
                    <?php
    				wp_pagenavi();
    				wp_reset_query();
    				?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] [Plugin: WP-PageNavi] Trying to fix "Warning: You forgot to set the 'paged' query var’ is closed to new replies.