Forums

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

  1. avato
    Member
    Posted 2 years 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
    Volunteer
    Posted 2 years 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 years 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
    Volunteer
    Posted 2 years 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 years ago #

    That worked perfectly thank you so much!

Topic Closed

This topic has been closed to new replies.

About this Topic