• I’ve even tried a paid WP answers site and nobody can figure this out! Maybe checking out that link will give us a few hints as to the solution, somebody has to know how to do this: http://wpquestions.com/question/show/id/1352

    Right now I’m telling the code to pull up two posts per archive page in my portfolio category. But when I click the older entries button it doesn’t find the other posts in that category, it sends me to my 404 error page. I need to get the other posts to show when I click older entries.

    Link: http://lucaswynne.com/category/portfolio/

    Extra note: I want to still be able to use WP’s settings to show a maximum number of posts and don’t want those settings to affect my portfolio page.

    <?php get_header(); ?>
    
    <div id="portfolio_content">
    
    <!-- Grab posts -->
    <?php if (query_posts('posts_per_page=2')) : ?>
    <?php while (have_posts()) : the_post(); ?>
    
    <div style="width:980px; background:#000">
    
    <div class="img">
    <a href="<?php the_permalink() ?>">
    <?php $image = catch_that_image();
    if( $image ) { ?>
    <img src="<?php echo $image; ?>"  alt="<?php the_title(); ?>" title="<?php the_title(); ?>, <?php comments_number('No comments','One comment','% comments'); ?>" />
    <?php } ?>
    </a>
      <div class="title"><?php the_title(); ?></div>
      <div class="desc">Add a description of the image here</div>
    </div>
    </div>
    
    <?php endwhile; ?>
    <?php endif; ?>
    
    <!-- Next/Previous Posts -->
    <div class="mp_archive">
    <div id="more_posts">
    <div class="oe"><?php next_posts_link('« Older Entries') ?></div><div class="re"><?php previous_posts_link ('Recent Entries »') ?></div>
    </div>
    </div>
    
    </div>
    </div>
    <?php get_footer(); ?>
Viewing 7 replies - 1 through 7 (of 7 total)
  • http://www.rvoodoo.com/projects/wordpress/wordpress-tip-fixing-pagination-on-custom-queries-with-query_posts/

    is it related to this? When you use a custom query, you have to account for pagination in the query…..

    Thread Starter signalnorth

    (@signalnorth)

    I think that may be the solution. But for some reason it only wants to show one post now, even though I have 5 in the category and have assigned the category. Hmm. Any ideas?

    I’m using 3.0.3.

    Thread Starter signalnorth

    (@signalnorth)

    Ok, I have it showing as many as I want now – but still the error on the second page.

    <?php query_posts( array(
    		// Set post query
    		'posts_per_page' => 2,
    		// Enabled paging
    		'paged'=> ( get_query_var('paged') ? get_query_var('paged') : 1 ),
    	)); ?>
             <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    maybe separate out your query from your loop start?

    Thread Starter signalnorth

    (@signalnorth)

    That code isn’t doing much to help. If I use this though:

    <?php query_posts('posts_per_page=');
    if ( have_posts() ) : while (have_posts()) : the_post(); ?>

    I get posts, but it’s now repeating the posts instead of showing the previous posts like it should be.

    right, that’s what my code is intended to help with. It makes the pagination work. Without it, the posts keep repeating. If you are using any sort of query, you have to include pagination.

    Not sure where the issue lies on your page…. I copied the code out of my theme, and it works perfectly……

    did you add my code to yours, or replace it? My code was intended to replace

    <?php if (query_posts('posts_per_page=2')) : ?>
    <?php while (have_posts()) : the_post(); ?>

    on your template, not add to it….. also, I slightly edited my code…. I had apostrophes around the 2, they shouldn’t be there

    Just for example, here’s another version I have that is working perfectly

    query_posts( array(
    	// Set post type
    	'post_type' => 've_members',
    	'posts_per_page' => 12,
    	'orderby' => 'ID',
    	'order' => 'ASC',
    	// Enabled paging
    	'paged'=> ( get_query_var('paged') ? get_query_var('paged') : 1 ),
    ));
    
    get_header();
    ?>
    
    <?php if (have_posts()) : ?>
    
    	<div>
    
    		<?php while (have_posts()) : the_post(); ?>

    Just so you can see a query with more parameters, which still includes the pagination

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘The WP Mystery Code!’ is closed to new replies.