• Resolved GoffeyUK

    (@goffeyuk)


    Hello,

    I’m hoping one of you wordpress geniuses out there, would be able to help me with an issue i’m experiencing?

    I’ve been searching for the solution for a while now, and thanks to the support forum already, i’ve been able to construct the following query:

    <?php
    $paged = (get_query_var('page')) ? get_query_var('page') : 1;
    echo $paged;
    $args = query_posts(array('posts_per_page' => 1,'paged'=>$paged, 'post_type' => array('post','movie','game','mma','football'),
                              'orderby'=> menu_order
                             ));
    $loop = new WP_Query( $args );
    if (have_posts()) {?>
    
        <div class="column-container">
            <ul>
                <?php } ?>
                <?php while ( have_posts() ) : the_post(); ?>
    
                <li>
                    <a href="<?php the_permalink(); ?> "> <h3><?php the_title(); ?></h3></a>
                            <?php echo get_the_excerpt(); ?>
    
                </li>
                <?php endwhile; ?>
                <?php if (have_posts()) {?>
            </ul>
        </div>
    <?php } ?>
    
    <?php previous_posts_link('&laquo; Previous') ?>
    <?php next_posts_link('More &raquo;') ?>

    What i’m trying to achieve is a loop, that loops through all my custom post types (including the default post) and out put them in a list, that has pagination.

    Now i’ve partially got this working, I’ve got the pagination working, but for some reason, the first post (the latest created) is duplicated. It appears first in the query, and also last in the query.

    For example, in the code above, i only have one post per page (just to test the pagination) and the post on the first page, also appears on the last page in the pagination.

    Any ideas how i could fix this would be greatly appreciated!

Viewing 1 replies (of 1 total)
  • Thread Starter GoffeyUK

    (@goffeyuk)

    So it turns out, it had something to do with the orderby part of the query. Not sure why menu_order would duplicate a page but it did. Changing jt to date solved the issue for me.

Viewing 1 replies (of 1 total)

The topic ‘multiple custom post types and pagination issue’ is closed to new replies.