• Resolved juahan

    (@juahan)


    I’m puzzled. Idea is that I have different categories of posts and there is a page created for each category. Each page should show one post from its designated category.

    I use the following on the created page.

    <?php
    
    //The Query
    query_posts('posts_per_page=1&cat=4');
    
    //The Loop ?>
    
    	<?php if (have_posts()) : ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    
    		...
    
    		<?php endwhile; ?>
    
    <?php next_posts_link('&laquo; Older') ?>
    <?php previous_posts_link('Newer &raquo;') ?>
    
    	<?php else : ?>
    
    	...
    
    	<?php endif; ?>
    
    <?php
    //Reset Query
    wp_reset_query();
    ?>

    It shows properly the first post from category, but then when I click “Older”-link, it displays the same first post again even if the address changes correctly to /wordpress/pagename/page/2 etc.

    Anyone have thoughs of what I’m doing wrong? Is there better way of doing this what I am trying to get done?

    And another question related to the previous one. Is there a code that I could use to echo the available $is_* variables? I mean, in a way like echoing all different “environmental variables” from a given page for debugging purposes.

Viewing 5 replies - 1 through 5 (of 5 total)
  • try and use:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args=array(
       'cat'=>4,
       'posts_per_page'=>1,
       'caller_get_posts'=>1,
       'paged'=>$paged,
       );
    query_posts($args);

    instead of:

    query_posts('posts_per_page=1&cat=4');

    Try replacing:

    query_posts('posts_per_page=1&cat=4');
    with:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args= array(
    	'posts_per_page' =>1,
    	'cat' => 4;
    	'paged' => $paged
    );
    query_posts($args);

    Thread Starter juahan

    (@juahan)

    Worked beautifully! Thank you for amazingly quick reply!

    i have exactly the same problem! but your solution is not working for me. =/

    this is what i have:

    <?php if (have_posts()) : ?>
    
    		<?php query_posts("category_name=$blog_cat");  ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    
    			<div class="postsingle" id="post-<?php the_ID(); ?>">
    
    				<h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
    
    				<p class="postmetadata">by <?php the_author(); ?> on <?php the_time('l, F jS, Y') ?>  | <img src="<?php echo get_bloginfo('template_directory'); ?>/images/comments.png" alt="comments"> <?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?> | <?php the_tags(); ?> </p>
    
    				<div class="entry">
    					<?php the_content('Read the rest of this entry &raquo;'); ?>
    				</div>
    
    			</div>
    
    		<?php endwhile; ?>
    
    		<div class="navigation">
    			<div class="alignleft"><?php next_posts_link('&larr; Older Entries') ?></div>
    			<div class="alignright"><?php previous_posts_link('Newer Entries &rarr;') ?></div>
    		</div>
    
    	<?php else : ?>

    i tryed to replace
    'cat' => 4; with
    with
    'category_name' => $blog_cat

    someone an idea?

    @esmi’s solution works great.

    I had no need for the 'caller_get_posts'=>1 variable.

    Where can I find out more about why this works?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Page and next_posts_link – Doesn’t work properly’ is closed to new replies.