• Hi, I am like totally new to the wp query function on the php side of wordpress. I have been stuck on this issue for a while.

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts(array('posts_per_page'=>get_option('premiumwd_blog_perpage') )); $loop = new WP_Query( array('paged'=>$paged, 'orderby' => 'menu_order') );  ?>
    <?php $show_category = exclude_header_cats(); $query = new WP_Query( 'cat='.$show_category  ); ?>
    <?php if ($query->have_posts()) : ?>
    <?php while ( $query->have_posts() ) : $query->the_post(); ?>

    Standard wordpress pagination on the footer, any clue on how to make this work?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Not sure what you are trying to achieve. You have 3 queries: 1 query_posts(), 2 WP_Queries. Please explain why you need 3, as standard WP pagination works for only 1.

    Thread Starter crod310

    (@crod310)

    I have a query one for my theme options to include which categories

    <?php $show_category = exclude_header_cats(); $query = new WP_Query( 'cat='.$show_category ); ?>

    This query is for my theme options to tell is how many per page:

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts(array('posts_per_page'=>get_option('premiumwd_blog_perpage') ));

    Thread Starter crod310

    (@crod310)

    the rest is just to toggle the pagination, im pretty much blind just adding random stuff after that

    I think you might not understand how a query works. Each query retrieves a set of posts from the database, replacing any from a previous query. So only the posts from the last query are available.

    I can’t see what follows the code you posted, so this may not be exactly correct, but should give you the idea: put all the arguments into a single query. Try replacing your code with this:

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array(
       'paged' => $paged,
       'posts_per_page' => get_option('premiumwd_blog_perpage'),
       'orderby' => 'menu_order',
       'cat' => exclude_header_cats(),
    );
    query_posts($args);
    if ( have_posts() ) :
       while ( have_posts() ) : the_post();
    ?>
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom WordPress Query Pagination Not Working’ is closed to new replies.