Support » Fixing WordPress » pagination – custom query – not displaying

  • Hello,

    Like many others I have a custom query that results in the page navigation returning the same page over and over. I have looked at the forum, i have tried a few things but to no avail.

    Here is the query

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
                <?php echo the_content() ?>
    	        <?php endwhile; else: ?>
    		        <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    			<?php endif; ?>
                                <?php
    				$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    				$args = array(
    				'post_type' => 'post',
    				'posts_per_page'=>'8',
                                    'paged' => '$paged',
    				'order' => 'DESC'
    			);
    			$query = new WP_Query( $args );
    			query_posts($args);
    			$count = 1;?>
    
                <?php if ($query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();
    			?>

    Any help appreciated. Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • definitively remove query_posts($args);

    where is your code for the pagination?

    please post the full code of the template.

    thanks michael. sorry i was expecting that i would receive an email if someone replied. here is the full template

    <?php
    /*
    Template Name: News
    */
    
    get_header();?>
    
    <section id="content-wide">
        <section id="content-container" class="container_12">
            <article id="content" class="grid_9 alpha news-list">
                <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
                <?php echo the_content() ?>
    	        <?php endwhile; else: ?>
    		        <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    			<?php endif; ?>
                                <?php
    				$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    				$args = array(
    				'post_type' => 'post',
    				'posts_per_page'=>'8',
                                    'paged' => '$paged',
    				'order' => 'DESC'
    			);
    			$query = new WP_Query( $args );
    			query_posts($args);
    			$count = 1;?>
    
                <?php if ($query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();
    			?>
    <article class="news-post">
    <p class="date"><?php echo get_the_date();?></p>
    		<h2><?php the_title();?></h2>
    		<?php if(get_field('article_source')){?>
    		<p><a href="<?php the_field('article_source_url');?>"><?php the_field('article_source');?></a></p>
    		<?php } ?>
                <?php the_excerpt() ?>
    <?php if(get_field('video_embed')){?>
    <div class="video">
    <?php the_field('video_embed');?>
    </div>
    <?php } elseif ( has_post_thumbnail() ) {
      the_post_thumbnail('largethumb');
    }
    ?>
    <div class="meta">
    <p><?php echo get_the_term_list( $post->ID, 'category', 'Category: ', ', ', '' ); ?></p>
    
    	<div class="social-shares">
    	<div class="fb-like" data-href="<?php the_permalink();?>" data-layout="button" data-action="like" data-show-faces="false" data-share="true"></div>
    	<a href="https://twitter.com/share" class="twitter-share-button" data-lang="en" data-url="<?php the_permalink();?>" data-text="<?php the_title();?>" data-count="none">Tweet</a>
    	</div>
    
    <a class="read-more" href="<?php the_permalink();?>">More</a>
    
    </div>
    
    </article>
    	        <?php
    			endwhile; else: ?>
    		        <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    			<?php endif; ?>
    <div class="navigation">
    
    <div class="alignright nav-previous"><?php next_posts_link('Previous Entries &raquo;') ?></div>
    <div class="alignleft nav-next"><?php previous_posts_link(' &laquo; Next Entries','') ?></div></div>
    		</article>
    
    <aside class="grid_3 omega">
    
    <div class="category-list">
        <h3>Categories</h3>
    <?php $args = array(
    	'orderby'            => 'name',
    	'order'              => 'ASC',
    	'style'              => 'none',
    	'title_li'           => ''
    ); ?>
     <?php wp_list_categories($args); ?>
    </div>
    
    </aside>
    	</section>
    </section>
    
    <div class="clear"></div>
    </section>
    </section>
    
    <?php get_footer() ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘pagination – custom query – not displaying’ is closed to new replies.