• Resolved micalopes

    (@micalopes)


    Good morning! (Sorry my bad English, I′m a brazilian girl ?? )

    I’m with that problem in pagination when using query_post.
    ‘ve Tried countless codes, including:

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
    
    <?php query_posts('cat=5&showposts=5&paged=$paged'); ?>
    
    <?php if (have_posts()) : ?>
    
    <?php while (have_posts()) : the_post(); ?>

    Did not work …
    The only difference, I’m using query_post like this:
    <?php if (is_page('ultimas-noticias')) {query_posts('category_name=Notícias');}?>

    Can anyone give me a help?
    The code of my index.php is:

    <?php get_header(); ?>
    
    <?php if (is_front_page()){include ('sidebar.php'); }
    	if (is_page('nossa-historia')) {include ('sidebar.php'); }
    	if (is_page('nosso-estatuto')) {include ('sidebar.php'); }
    	if (is_home()) {include ('sidebar.php'); }
    	if (is_home()) {query_posts('cat=-3, -6, -7, -8, -9'); }
    	if (is_page('membros')) {include ('sidebar3.php'); }
    	if (is_page('membros-do-staff')) {include ('sidebar3.php'); }
    	if (is_page('membros-oficiais')) {include ('sidebar3.php'); }
    	if (is_page('membros-em-reserva')) {include ('sidebar3.php'); }
    	if (is_page('novos-membros')) {include ('sidebar3.php'); }
    	if (is_page('membros-em-aprovacao')) {include ('sidebar3.php'); }
    	if (is_page('eventos')) {include ('sidebar4.php'); }
    	if (is_page('standards')) {include ('sidebar5.php'); }
    	if (is_page('participe')) {include ('sidebar6.php'); }
    	if (is_page('contato')) {include ('sidebar7.php'); }
    ?>
    
    		<!-- Content -->
    
    		<div id="content">
    
                <?php if (is_page('ultimas-noticias')) {query_posts('category_name=Notícias');}?>
                <?php if (is_page('membros-do-staff')) {query_posts('category_name=Membros do Staff&order=ASC') ;}?>
    			<?php if (is_page('membros-oficiais')) {query_posts('category_name=Membros Oficiais&order=ASC');}?>
                <?php if (is_page('membros-em-reserva')) {query_posts('category_name=Membros em Reserva&order=ASC');}?>
                <?php if (is_page('novos-membros')) {query_posts('category_name=Novos Membros&order=ASC');}?>
                <?php if (is_page('membros-em-aprovacao')) {query_posts('category_name=Membros em Aprova?ao&order=ASC');}?>
    <?php
    global $more;    // Declare global $more (before the loop).
    $more = 0;       // Set (inside the loop) to display all content, including text below more.
    the_content();
    ?>
    
    			<?php if (have_posts()) : ?>
    			<?php while (have_posts()) : the_post(); ?>
    
    			<!-- Post -->
    
    			<div class="post" id="post-<?php the_ID(); ?>">
    
    				<div class="post-title">
    
    					<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    
    					<div class="post-title-info">
    
                        Por: <?php the_author() ?> em  <?php the_time('d/m/Y') ?><br />
    
                        </div>
    
                        <div class="clear"></div>
    
    				</div>
    
    				<div class="post-entry">
    
    					<?php the_content('Leia mais...'); ?>
    
    				</div>
    
    				<div class="post-info">
    
    				</div>
    
    			</div>
    
    			<!-- /Post -->
    
    			<?php endwhile; ?>
    
    			<!-- Navigation -->
    
    			<div class="navigation">
    
    				<div class="navigation-previous"><?php next_posts_link('&laquo; Anterior') ?></div>
    
    				<div class="navigation-next"><?php previous_posts_link('Pr&oacute;xima &raquo;') ?></div>
    
    			</div>
    
    			<!-- /Navigation -->
    
    			<?php else : ?>
    
    			<!-- Post -->
    
    			<div class="post">
    
    				<div class="post-title">
    
    					<h2>Not Found</h2>
    
    				</div>
    
    				<div class="post-entry">
    
    					<p>Sorry, but you are looking for something that isn't here.</p>
    
    				</div>
    
    			</div>
    
    			<!-- /Post -->
    
    			<?php endif; ?>
    
    			<div class="clear"></div>
    
    		</div>
    
    		<!-- /Content -->
    
    <?php include (TEMPLATEPATH . '/sidebar-right.php'); ?>
    
    <?php get_footer(); ?>

    Thanks!!!!!!

Viewing 9 replies - 1 through 9 (of 9 total)
  • Use
    <?php query_posts('cat=5&showposts=5&paged=' . $paged); ?>
    or
    <?php query_posts("cat=5&showposts=5&paged=$paged"); ?>

    Thread Starter micalopes

    (@micalopes)

    Not work ??

    <?php get_header(); ?>
    
    <?php if (is_front_page()){include ('sidebar.php'); }
    	if (is_page('nossa-historia')) {include ('sidebar.php'); }
    	if (is_page('nosso-estatuto')) {include ('sidebar.php'); }
    	if (is_home()) {include ('sidebar.php'); }
    	if (is_home()) {query_posts('cat=-3, -6, -7, -8, -9'); }
    	if (is_page('membros')) {include ('sidebar3.php'); }
    	if (is_page('membros-do-staff')) {include ('sidebar3.php'); }
    	if (is_page('membros-oficiais')) {include ('sidebar3.php'); }
    	if (is_page('membros-em-reserva')) {include ('sidebar3.php'); }
    	if (is_page('novos-membros')) {include ('sidebar3.php'); }
    	if (is_page('membros-em-aprovacao')) {include ('sidebar3.php'); }
    	if (is_page('eventos')) {include ('sidebar4.php'); }
    	if (is_page('standards')) {include ('sidebar5.php'); }
    	if (is_page('participe')) {include ('sidebar6.php'); }
    	if (is_page('contato')) {include ('sidebar7.php'); }
    ?>
    
    		<!-- Content -->
    
    		<div id="content">
                <?php if (is_page('ultimas-noticias')) {query_posts('category_name=Notícias');}?>
                <?php if (is_page('membros-do-staff')) {query_posts('category_name=Membros do Staff&order=ASC') ;}?>
    			<?php if (is_page('membros-oficiais')) {query_posts('category_name=Membros Oficiais&order=ASC');}?>
                <?php if (is_page('membros-em-reserva')) {query_posts('category_name=Membros em Reserva&order=ASC');}?>
                <?php if (is_page('novos-membros')) {query_posts('category_name=Novos Membros&order=ASC');}?>
                <?php if (is_page('membros-em-aprovacao')) {query_posts('category_name=Membros em Aprova?ao&order=ASC');}?>
    <?php
    global $more;
    $more = 0;
    the_content();
    ?>
    
    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
    
    <?php query_posts('cat=6&showposts=4&paged=' . $paged); ?>
    
    <?php if (have_posts()) : ?>
    
    <?php while (have_posts()) : the_post(); ?>
    			<!-- Post -->
    
    			<div class="post" id="post-<?php the_ID(); ?>">
    
    				<div class="post-title">
    
    					<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    
    					<div class="post-title-info">
    
                        Por: <?php the_author() ?> em  <?php the_time('d/m/Y') ?><br />
    
                        </div>
    
                        <div class="clear"></div>
    
    				</div>
    
    				<div class="post-entry">
    
    					<?php the_content('Leia mais...'); ?>
    
    				</div>
    
    				<div class="post-info">
    
    				</div>
    
    			</div>
    
    			<!-- /Post -->
    
    			<?php endwhile; ?>
    
    			<!-- Navigation -->
    
    			<div class="navigation">
    
    				<div class="navigation-previous"><?php next_posts_link('&laquo; Anterior') ?></div>
    
    				<div class="navigation-next"><?php previous_posts_link('Pr&oacute;xima &raquo;') ?></div>
    
    			</div>
    
    			<!-- /Navigation -->
    
    			<?php else : ?>
    
    			<!-- Post -->
    
    			<div class="post">
    
    				<div class="post-title">
    
    					<h2>Not Found</h2>
    
    				</div>
    
    				<div class="post-entry">
    
    					<p>Sorry, but you are looking for something that isn't here.</p>
    
    				</div>
    
    			</div>
    
    			<!-- /Post -->
    
    			<?php endif; ?>
    
    			<div class="clear"></div>
    
    		</div>
    
    		<!-- /Content -->
    
    <?php include (TEMPLATEPATH . '/sidebar-right.php'); ?>
    
    <?php get_footer(); ?>

    try and add the ‘&paged=’ .$paged’ bit to each query_posts in your conditional list:

    <div id="content">
    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
               <?php if (is_page('ultimas-noticias')) {query_posts('category_name=Notícias&paged=' . $paged);}?>
                <?php if (is_page('membros-do-staff')) {query_posts('category_name=Membros do Staff&order=ASC&paged=' . $paged) ;}?>
    			<?php if (is_page('membros-oficiais')) {query_posts('category_name=Membros Oficiais&order=ASC&paged=' . $paged);}?>
                <?php if (is_page('membros-em-reserva')) {query_posts('category_name=Membros em Reserva&order=ASC&paged=' . $paged);}?>
                <?php if (is_page('novos-membros')) {query_posts('category_name=Novos Membros&order=ASC&paged=' . $paged);}?>
                <?php if (is_page('membros-em-aprovacao')) {query_posts('category_name=Membros em Aprova?ao&order=ASC&paged=' . $paged);}?>
    <?php
    global $more;    // Declare global $more (before the loop).
    $more = 0;       // Set (inside the loop) to display all content, including text below more.
    ?>
    
    	<?php if (have_posts()) : ?>

    hope that helps ??

    Thread Starter micalopes

    (@micalopes)

    :′( not work…

    <?php get_header(); ?>
    
    <?php if (is_front_page()){include ('sidebar.php'); }
    	if (is_page('nossa-historia')) {include ('sidebar.php'); }
    	if (is_page('nosso-estatuto')) {include ('sidebar.php'); }
    	if (is_home()) {include ('sidebar.php'); }
    	if (is_home()) {query_posts('cat=-3, -6, -7, -8, -9'); }
    	if (is_page('membros')) {include ('sidebar3.php'); }
    	if (is_page('membros-do-staff')) {include ('sidebar3.php'); }
    	if (is_page('membros-oficiais')) {include ('sidebar3.php'); }
    	if (is_page('membros-em-reserva')) {include ('sidebar3.php'); }
    	if (is_page('novos-membros')) {include ('sidebar3.php'); }
    	if (is_page('membros-em-aprovacao')) {include ('sidebar3.php'); }
    	if (is_page('eventos')) {include ('sidebar4.php'); }
    	if (is_page('standards')) {include ('sidebar5.php'); }
    	if (is_page('participe')) {include ('sidebar6.php'); }
    	if (is_page('contato')) {include ('sidebar7.php'); }
    ?>
    
    		<!-- Content -->
    
    		<div id="content">
    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
               <?php if (is_page('ultimas-noticias')) {query_posts('category_name=Notícias&paged=' . $paged);}?>
                <?php if (is_page('membros-do-staff')) {query_posts('category_name=Membros do Staff&order=ASC&paged=' . $paged) ;}?>
    			<?php if (is_page('membros-oficiais')) {query_posts('category_name=Membros Oficiais&order=ASC&paged=' . $paged);}?>
                <?php if (is_page('membros-em-reserva')) {query_posts('category_name=Membros em Reserva&order=ASC&paged=' . $paged);}?>
                <?php if (is_page('novos-membros')) {query_posts('category_name=Novos Membros&order=ASC&paged=' . $paged);}?>
                <?php if (is_page('membros-em-aprovacao')) {query_posts('category_name=Membros em Aprova?ao&order=ASC&paged=' . $paged);}?>
    <?php
    global $more;
    $more = 0;
    ?>
    
    	<?php if (have_posts()) : ?>
    
    <?php while (have_posts()) : the_post(); ?>
    			<!-- Post -->
    
    			<div class="post" id="post-<?php the_ID(); ?>">
    
    				<div class="post-title">
    
    					<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    
    					<div class="post-title-info">
    
                        Por: <?php the_author() ?> em  <?php the_time('d/m/Y') ?><br />
    
                        </div>
    
                        <div class="clear"></div>
    
    				</div>
    
    				<div class="post-entry">
    
    					<?php the_content('Leia mais...'); ?>
    
    				</div>
    
    				<div class="post-info">
    
    				</div>
    
    			</div>
    
    			<!-- /Post -->
    
    			<?php endwhile; ?>
    
    			<!-- Navigation -->
    
    			<div class="navigation">
    
    				<div class="navigation-previous"><?php next_posts_link('&laquo; Anterior') ?></div>
    
    				<div class="navigation-next"><?php previous_posts_link('Pr&oacute;xima &raquo;') ?></div>
    
    			</div>
    
    			<!-- /Navigation -->
    
    			<?php else : ?>
    
    			<!-- Post -->
    
    			<div class="post">
    
    				<div class="post-title">
    
    					<h2>Not Found</h2>
    
    				</div>
    
    				<div class="post-entry">
    
    					<p>Sorry, but you are looking for something that isn't here.</p>
    
    				</div>
    
    			</div>
    
    			<!-- /Post -->
    
    			<?php endif; ?>
    
    			<div class="clear"></div>
    
    		</div>
    
    		<!-- /Content -->
    
    <?php include (TEMPLATEPATH . '/sidebar-right.php'); ?>
    
    <?php get_footer(); ?>

    ?? ?? ??

    Is there other loop with query_posts in sidebarx.php?
    You must write wp_reset_query() to close query_post().

    Get rid of showposts and replace it with posts_per_page, in your query_posts line.

    another thought: what if all the ifs are not true, would you need another ‘else’ query?

    You have another query_posts near the top:

    if (is_home()) {query_posts('cat=-3, -6, -7, -8, -9'); }

    Is that the one not working? Maybe you need to move it down after you set $paged and add the paged parameter to it.

    Thread Starter micalopes

    (@micalopes)

    Thanks!!!!!!! vtxyzzy!!!!!

    Now it′s work!!!!!

    Thanks!!!!! ?? ?? ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Code for pagination query_post not work’ is closed to new replies.