• For the index page on my site I am displaying Uncategorized posts and posts of a particular category called “Gigs”, using two separate loops. I want to be able to use blog pages (limiting a certain number of posts to be displayed per page) with the Uncategorized posts, without affecting the Gigs posts.

    Here’s my code so far:

    <div class="gig_schedule">
    <h4>Gig Schedule</h4>

    <?php query_posts('category_name=Gigs&showposts=10'); ?>

    <?php if (have_posts()) : ?>

    <?php while (have_posts()) : the_post(); ?>
    <b><?php the_date('F j') ?></b> - <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>

    <?php endwhile; ?>

    <?php else : ?>
    No gigs are currently scheduled.

    <?php endif; ?>
    </div>

    <?php query_posts('category_name=Uncategorized'); ?>

    <?php if (have_posts()) : ?>

    <?php while (have_posts()) : the_post(); ?>
    <h3><?php the_title(); ?></h3>
    <h4><?php the_date() ?></h4>
    <?php the_content(); ?>
    <p class="cite"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent link for <?php the_title(); ?>">#</a> | Posted by <?php the_author() ?> at <?php the_time() ?> | <?php edit_post_link('Edit','','|'); ?> <?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?>

    <?php endwhile; ?>

    <div class="navigation">
    <div class="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div>
    <div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div>
    </div>

    <?php else : ?>

    <?php endif; ?>

    Any ideas?

Viewing 15 replies - 1 through 15 (of 26 total)
  • What’s happening with the code you supplied? In what way is it not working as expected?

    Have you read the Multiple Loops documentation?

    Thread Starter mrd516

    (@mrd516)

    Yes, I have read the multiple loops documentation. That’s how I learned how to use multiple loops in the first place.

    The pagination is not working. I set the limit for the number of posts per page, it displays the newest of that limit (whether it be, 1, 5, 10, etc.), and when I click the “Previous entries” link it simply doesn’t change anything.

    I have the same problem, I have three columns in my site, each one is a different loop, and I have that working fine but the previous entries doesn’t work anymore. We need someone who can help us all out.

    Thread Starter mrd516

    (@mrd516)

    It’s been about 2 days and this post is already completely buried. I, and atleast one other person would really appreciate some assistance with this.

    I’m sorry if I’ve violated any sort of “no bumping” rule, but I felt it was necessary.

    Thread Starter mrd516

    (@mrd516)

    It’s been a week now, and still no help. This issue still needs to be resolved and I’d really appreciate some advice here.

    I haven’t verified this method myself. Here goes..
    1. I’m assuming that you want to navigate the “Uncategorized”

    2. You need the following plugin to make “the built-in” Loop to display only the “Uncategorized”. Activate, set it up and you should only see “Uncategorized” in the front page.
    https://dev.wp-plugins.org/file/front-page-cats/trunk/front_page_cats.php

    3. Above the “built-in” Loop, create another loop with from the following page, the third example under Multiple Loops Example 1
    https://codex.www.ads-software.com/The_Loop#Multiple_Loops_Example_1

    4. Tell us how it goes. Good luck.

    Thread Starter mrd516

    (@mrd516)

    It seems rather unnecessary to use a plugin to only display posts of a particular category within the main loop. Wouldn’t it be easier to just put an if test within the loop to accomplish this?

    Anyway, I’ve altered my index file as follows, and now the Previous/Next Entries links just don’t show up at all.

    <?php get_header(); ?>

    <div class="gig_schedule">
    <h4>Gig Schedule</h4>

    <?php $my_query = new WP_Query('category_name=Gigs&showposts=10'); ?>

    <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
    <b><?php echo get_post_meta($post->ID, date, true); ?></b> - <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>

    <?php endwhile; ?>

    </div>

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    <?php if (in_category('1')) { ?>
    <h3><?php the_title(); ?></h3>
    <?php the_content(); ?>
    <p class="cite"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent link for <?php the_title(); ?>">#</a> | Posted by <?php the_author() ?> on <?php the_date() ?> | <?php edit_post_link('Edit','','|'); ?> <?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?>

    <?php } ?>

    <?php endwhile; ?>

    <div class="navigation">
    <div class="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div>
    <div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div>
    </div>

    <?php else : ?>

    <?php endif; ?>

    <div class="meta">
    <a href="wp-rss2.php" title="Syndicate this site with RSS 2.0"><img src="rss2.gif" alt="Rss 2.0" /></a> <a href="wp-atom.php" title="Syndicate this site with Atom 0.3"><img src="atom03.gif" alt="Atom 0.3" /></a> <a href="https://www.ads-software.com&quot; title="Powered by WordPress"><img src="wordpress.gif" alt="WordPress" /></a>
    </div>

    <?php get_footer(); ?>

    Use the following for page navigation
    https://codex.www.ads-software.com/Template_Tags/posts_nav_link

    EDIT: one day you’ll understand why you need that plugin ??

    Oh yeah, next time post your code right on the following site.
    https://pastebin.com

    Thread Starter mrd516

    (@mrd516)

    Okay, I replaced the Kubrick theme format for posts navigation with the posts_nav_link function, and no difference (just as I expected).

    Thread Starter mrd516

    (@mrd516)

    Well, I tried the plugin, and it only generated a slew of database errors. I think I was closer to the solution without it.

    Next suggestion?

    So the post navigation link still not showing up?

    If you look at the html source code, is it empty, too?

    I just tried your code and it worked. What plugins are active? You want me to dive in to your blog? alphaoide at g mail dotcom

    Thread Starter mrd516

    (@mrd516)

    When I tried the plugin I got a bunch of errors and my 2nd loop didn’t even work, though the main loop did. I think I was closer to the solution without this plugin.

    I don’t have any other plugins activated.

    I don’t see the need for you to “dive” into my blog, I’ve pasted all of the code from my index file, for you and everyone else to see. I’d really appreciate it if someone could just examine the code and figure out what the problem is.

    Well, like I said, your code works on my blog. I cut and pasted and change the category, and that’s it.

    Well, like I asked, for the code that you have pasted up there, you didn’t get the link navigation; but if you look at the html source code, is there no link either?

Viewing 15 replies - 1 through 15 (of 26 total)
  • The topic ‘Using blog pages with multiple loops’ is closed to new replies.