• Resolved tymayn

    (@tymayn)


    Ahoy friends of the WordPress realm.

    I have created a large theme for a filming company and am having issues displaying previous results when I list 10 posts of a single category per page. This may have to do with the way I setup the theme.

    Basically, I wanted the ‘News’ & ‘Where are We Now’ pages to be somewhat like an archives page just customized showing 10 posts in that category. Simple enough?

    I made the pages based off of template pages I created that were based off the Archive.php. I am wondering if has something to do with the fact that its a template page because it seems to work fine on the normal Arhcive’d pages.

    If I click the Previous Posts on these pages it loads a new page, but it has the same results. The strange part is it acts like its right, for instance, the ‘Whe Are We Now’ section will only go back once because there are only 12 entries, this not letting it go back any further, but it still has the same 10 posts on the page.

    Here’s the ‘news’ section link – https://www.process-films.com/news – when you click ‘Older Entries’ at the bottom the same 10 display.

    Here is the code –

    <?php
    /*
    Template Name: NEWS_TMPLATE
    */
    ?>
    
    <?php get_header(); ?> 
    
    <div id="post_content_left_holder">
    
    	<?php
    	query_posts('category_name=News');
    	if (have_posts()) : ?>
    
            <h3 class="title" style="width:200px;">News <img src="<?php bloginfo('template_directory'); ?>/images/process_bullet.png" align="absbottom" /></h3>
          <br />
    
    		<?php while (have_posts()) : the_post();
    		$thumb = get_post_meta($post->ID, 'large_preview', $single = true);?>
    
    		<div class="archive_style">
    
            		<div id="date_holder">
        <div id="date_day" align="right"><?php the_time('d'); ?></div><div id="date_suffix" align="left"><?php the_time('S'); ?></div>
        <div id="date_month" align="center"><?php the_time('F'); ?> <?php the_time('Y'); ?> </div>
        </div>
    
        <div class="pic_holder">
                <div id="test">
            <a href="<?php the_permalink( ); ?>">    <?php // if there's a thumbnail
    if($thumb !== '') { ?>
    
    	<img src="<?php echo $thumb; ?>"
        class="large_thumb"
        border="0"
    	/>
    
    <?php } // end if statement
    
    // if there's not a thumbnail
    else { echo ''; } ?> </a>
            </div>
        </div>
    
            		<div class="archive_entry">
    
    				<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
    
    				<div class="entry">
    					<?php the_excerpt() ?>
    				</div>
    
    				<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
    
    			</div>
    
    			</div>
    
    		<?php endwhile; ?>
    
    		<div class="navigation">
    			<div class="alignleft"style="float:left;"><?php next_posts_link('&laquo; Older Entries') ?></div>
    			<div class="alignright" style="float:right;"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
                <br />
    <br />
    
    		</div>
    	<?php else :
    
    		if ( is_category() ) { // If this is a category archive
    			printf("<h2 class='center'>Sorry, but there aren't any posts in the %s category yet.</h2>", single_cat_title('',false));
    		} else if ( is_date() ) { // If this is a date archive
    			echo("<h2>Sorry, but there aren't any posts with this date.</h2>");
    		} else if ( is_author() ) { // If this is a category archive
    			$userdata = get_userdatabylogin(get_query_var('author_name'));
    			printf("<h2 class='center'>Sorry, but there aren't any posts by %s yet.</h2>", $userdata->display_name);
    		} else {
    			echo("<h2 class='center'>No posts found.</h2>");
    		}
    		get_search_form();
    
    	endif;
    ?>
    
    </div>
    <!-- /Div Above Closing Content -->
    
    <?php get_sidebar(); ?>
    
    <br style="clear:both;" />
    
    <?php get_footer(); ?>

    Thank you for looking and helping, i’d buy you a drink at the pub if you help me fix this. ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must include pagination in your query_posts:

    <?php
       $paged = (get_query_var_('paged')) ? get_query_var('paged') : 1;
       query_posts('category_name=News&paged=' . $paged);
       if (have_posts()) : ?>
    Thread Starter tymayn

    (@tymayn)

    You sir, are getting BEER!

    Thank you a ton. Your code worked marvelous minus the extra underscore in the get_query_var, but I noticed it and BLAMMOOO, went boom like dynamite!

    Cheers Again.

    Betrayed by the flying fingers! Glad you got it working.

    hey guys, i am having the EXACT same problem as this guy, but adding the pageantion to the query didn’t seem to work. I hoped it did =) heres my query.

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
        <?php query_posts('post_type=our_work&posts_per_page=12&orderby=rand' . $paged); // call random blog post ?>
    <?php if(have_posts()) : while(have_posts()) : the_post(); ?>
    <div class="grid_5a ourWorkImgWidth">
    <a href="<?php the_permalink(); ?>"><?php echo the_post_thumbnail(array(200,200,false)); ?></a>
    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    <?php the_excerpt(); ?>
    </div>
    
    <?php endwhile; ?>
    <div id="navLinks" align="center">
    <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); }else { ?>
    <?php next_posts_link('Next Page'); ?>
    <?php previous_posts_link('Back a Page'); } ?>
    </div>
    
    <?php endif; wp_reset_query();?>

    the site is currently under testing @ https://magicvideo.com/cms/work/

    nevermind, its too late in the day, I missed the

    &paged= before adding on the pageination informtion
    thank you vtxyzzy for your help here, I read every single one of your other posts on the subject =D

    Could you please help we with this as well? I have tried everything I could find in the forums to no avail.

    [code moderated per forum rules - please use the pastebin]

    your code was modded, so i cant really help you but if your loop is messed up previously make sure you look up in your code and reset any queries you have

    IE use a wp_reset_query(); function after you end any loop that starts with query_posts()

    query_posts() modifies the main loop and thus if you dont reset it you will ge weird pagination or broken pagination.

    the alternative to doing this
    query_posts($args); would be this $var = new WP_Query($args)

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘next_posts_link – displays same results’ is closed to new replies.