Forums

[resolved] Exclude category problem (query_posts) (5 posts)

  1. avato
    Member
    Posted 2 weeks ago #

    Hello,

    On my site i'm trying to have a blog section and a portfolio section and want to be able to blog as normal and post new portfolio item as a blog post, I've done this by creating the blog page excluding the portfolio category and the portfolio page only including the portfolio category. All works great until I get to the point where I need to go to previous entries. Page two, page three, page four is exactly the same as page one with both pages. Simply showing the same page over and over again.

    Anyone else had this problem, and fixed it?

    Appreciate any help.

  2. MichaelH
    moderator
    Posted 2 weeks ago #

    Not sure what your queries look like so will use this example

    proper pagination:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts('cat=1&showposts='.get_option('posts_per_page').'&paged=' . $paged);
    ?>
  3. avato
    Member
    Posted 2 weeks ago #

    Ooops sorry. Tried the code you said still did not work. My code is below.

    <?php if (have_posts()) : ?>
    
    <?php query_posts("cat=-8");  ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    
    			// Content Here
    
    		<?php endwhile; ?>
    
    			<span id="previous-entries"><?php next_posts_link('&laquo; Previous Entries') ?></span>
    			<span id="next-entries"><?php previous_posts_link('Next Entries &raquo;') ?></span>
    
    	<?php else : ?>
    
    	// not found content
    
    	<?php endif; ?>
  4. MichaelH
    moderator
    Posted 2 weeks ago #

    try

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts($query_string . '&cat=-3&paged=' . $paged);
    ?>
    <?php if (have_posts()) : ?>
    
    <?php while (have_posts()) : the_post(); ?>
    			// Content Here
    
    		<?php endwhile; ?>
    
    			<span id="previous-entries"><?php next_posts_link('&laquo; Previous Entries') ?></span>
    			<span id="next-entries"><?php previous_posts_link('Next Entries &raquo;') ?></span>
    
    	<?php else : ?>
    
    	// not found content
    
    	<?php endif; ?>

    `

  5. avato
    Member
    Posted 2 weeks ago #

    That worked perfectly thank you so much!

Reply

You must log in to post.

About this Topic