• Resolved james-smith

    (@james-smith)


    Hi

    My blog is here. I have 2 loops on the page, Loop1 is the center. Loop2 is the right-hand sidebar. Loop1 is paginated, and shows a single post, using this code:

    <?php if (have_posts()) : ?>
    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts('cat=19,20,&paged=$paged'); ?>
    <?php while (have_posts()) : the_post(); ?>

    When I click the Page Link I’m taken to the Single post page. There, the Loop2 produces errors. Loop2 is fine when you’re on the first page: and then it screws up on pages 2 and 3: Page 2, Page 3

    I have this code in Loop1 on the Single page:

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts('cat=19,20,&paged=$paged'); ?>

    When I remove that code, Loop2 is screwed up on ALL the pages, not just pages 2 and 3.

    Does anyone have any ideas? Thanks in advance.

Viewing 15 replies - 1 through 15 (of 19 total)
  • Hum… I don’t know if I understand what you’re trying to do…

    1- You have a index.php or a home.php with two loops :
    a) first loop in the center column to display one post with pagination.
    b) second loop in the right column to display some other posts

    2- Then, when you click on a permalink (the link to the post itself) in the center column, you’re directed to single.php where you want :
    a) the post displayed in the center column
    b) and the same loop as above in the right column to display some other posts.

    Tell me if I’m right.

    S.

    Thread Starter james-smith

    (@james-smith)

    Yeah, you were right. I accidentally got it to work by trying every query I could google. Now the issue is that pagination is broken.

    The Center column is displaying posts like this:

    <?php if (have_posts()) : ?>
    
      <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts($query_string.'showposts=1&cat=19,20&paged=$paged'); ?>  
    
           <?php while (have_posts()) : the_post(); ?>

    The Right column displays posts properly using any of these:

    <?php query_posts($query_string.'cat=-19,-20'); ?>
    <?php while (have_posts()) : the_post(); ?>

    or

    <?php
    $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts($query_string.'cat=-19,-20&showposts=2&paged=$page'); ?>
    <?php while (have_posts()) : the_post(); ?>

    or

    <?php
    $thePage = $_GET["paged"];
    query_posts("cat=-19,-20&paged=$thePage");
    <?php while (have_posts()) : the_post(); ?>
    ?>

    But, regardless of which code I use, pagination on BOTH columns is subsequently broken.

    I’ve been thinking about using SimplePie to feed my rss into one column or the other. But then if you wanted to see old posts, I’d have to load the entire archive into that column, and that seems a little ridiculous to me. There’s got to be a cleaner way.

    Any help is greatly appreciated.

    Hum… You want pagination on both column???

    Well… For now, try this :

    CENTER COLUMN HOME.PHP

    <?php
    $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("showposts=1&cat=19,20&paged=$page");
    ?>
    <?php while (have_posts()) : the_post(); ?>
    --- DO YOUR STUFF (title, hyperlink, date, author, content, etc.)---
    <?php endwhile; ?>
    <?php wp_reset_query(); ?>

    RIGHT-HAND COLUMN HOME.PHP

    <?php query_posts($query_string.'cat=-19,-20'); ?>
    <?php while (have_posts()) : the_post(); ?>
    --- DO YOUR STUFF (title, hyperlink, date, author, content, etc.)---
    <?php endwhile; ?>
    <?php wp_reset_query(); ?>

    And, of course, in single.php, in the center column, you use a standart loop, with no query_posts…

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

    And in the right-hand column of your single.php, you still display the same loop you use in home.php…

    <?php query_posts($query_string.'cat=-19,-20'); ?>
    <?php while (have_posts()) : the_post(); ?>
    --- DO YOUR STUFF (title, hyperlink, date, author, content, etc.)---
    <?php endwhile; ?>
    <?php wp_reset_query(); ?>

    S.

    Oh!

    Just realize I made a mistake in the first loop above… I made the correction :

    CENTER COLUMN HOME.PHP

    <?php
    $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("showposts=1&cat=19,20&paged=$page");
    ?>
    <?php while (have_posts()) : the_post(); ?>
    --- DO YOUR STUFF (title, hyperlink, date, author, content, etc.)---
    <?php endwhile; ?>
    <?php wp_reset_query(); ?>
    Thread Starter james-smith

    (@james-smith)

    It was a valiant effort, but no soap. I’ve decided to alter the design a little bit– I’m not going to try and get pagination working on both columns. I won’t hold it against you if you could help me get it working on the Right column though.

    This is what I’ve got working right now (the colors are just to see where everything is really located).

    Just to tell you, you also have a lot of css issues…

    Look at your validation

    Your pagination problem is probably not relative to these errors… But you rally not have three columns here. Your <body> tag seems to be misplaced, etc. In both i.e. and firefox, your grey right column appears under the left and center one. And in IE, your header appears like this :

    http://koolos.com/WP_DEV/share_img/jamesmith_blog.gif

    (these problem are here since the begining)

    —————————-

    To investigate deeper your problem, could you paste there :

    http://www.pastebin.ca/

    Your complete index.php, or home.php, where you are using these loop and the pagination. Then, give us the link to the complete code.

    S.

    Oh… And I forgot… Do the same with your sidebar… Paste the code in the pastebin.ca…

    S.

    Thread Starter james-smith

    (@james-smith)

    Hey, thanks very much for that. Here are the links…

    index.php

    sidebar.php (left column)

    sidebar3.php (right column)

    styles.css

    I knew the css was screwy, but I’d been focusing on trying to get the thing functional before trying to make it look good. Weird thing is, the it looks fine for me in Firefox on Windows.

    Anyway, thanks again.

    kewl kewl…

    Well..

    What is this code in the sidebar.php :

    <?php iinclude_page(11); ?>

    I know it comes from the include page plugin… It is this page wich contain the:

    <div class="ngg-galleryoverview" id="ngg-gallery-2">

    And the folowing… the slide show I see in your live html source… ?

    If yes, what do you have in this page/file ?

    S.

    Thread Starter james-smith

    (@james-smith)

    The code for iinclude_page is here.

    I haven’t edited it at all. The page that’s being included hasn’t had anything added either, I just made it a pretty basic page. It starts with the standard query:

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

    Hum…

    So where does the code for the slide show I see in your left side bar is coming from ?

    It start like this :
    <div class="ngg-galleryoverview" id="ngg-gallery-2">

    And it comes from the nggallery plugin…

    And what is the purpose to include page 11 in the sidebar ?

    ———————–

    What I suspect is that the culprit is Nextgen Gallery… Or another code/plugin in the sidebar…

    Your next troubleshooting step would be to make a straight three column with the loops I gave you yesterday for the center column and the right-hand one…

    Keep your sidebar.php (the left column) and the header.php as straight as possible… No special code, no plugin… Also, disable the plugins…

    Get your pagination and loops to work before adding any extras…

    S.

    Thread Starter james-smith

    (@james-smith)

    Ah, okay. The sidebar does this: <?php iinclude_page(11); ?> . Page 11 is where I put the gallery originally, so I just used the iinclude_page to grab it. I was really just trying to see if I could.

    You’re right about stripping out all the extras, but I should note that my problems started before putting the gallery in there.

    I was trying to update the template I already had in there, but I think you’re right and I should just start from scratch. I guess Kubrick is the best place to start?

    Kubrick is a hell to modify… 🙂

    I really don’t like the CSS structure…

    If you want to re-start from zero, you can take kubrick as an inspiration… And build your own…

    And in few hours, I will be done with my new project : The Simpliest WordPress Theme Ever… :-)) A sort of “base theme” to start with… I’ll give you a buzz when it will be done…

    —————

    The problem is that the loops I gave you above should really work… I tested it in my test installation, you can see it in action there :

    http://www.koolos.com/WP_DEV/

    As you see, it’s in french, but I have a list of posts on the right sidebar titled :—POSTS WITH QUERY_POSTS—

    And I have the same query_posts loop in the main column with the get_query_var('paged') and the pagination works…

    So the problem is not in these loops… It comes from elsewhere…

    S.

    Oh… And also… You wrote :

    You’re right about stripping out all the extras, but I should note that my problems started before putting the gallery in there.

    The problem is maybe not in this inclusion itself, but with a plugin… That’s why I would recommend to de-activate any plugin while you are building your theme…

    S.

    Thread Starter james-smith

    (@james-smith)

    In the sidebar, could you have the actual posts running there too, or can you only list them? And could you have them open in the sidebar, while the main column remains static? That’s what I was after, which may not even be possible. I don’t think css likes me very much.

    My email is jamesmith3 at gmail dot com if you want to email me when your base theme is done.

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘Multiple Loops and Pagination in conflict on Single.php’ is closed to new replies.