WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] My Loop ain't Runnin! (12 posts)

  1. kortschot
    Member
    Posted 3 years ago #

    Can anybody shed some light on my Loop... the second part posts the permalink of the page instead of the remaining posts in the category.... I must be doing something wrong.

    <div id="main-content-werk">
    
            <div id="slider">
              <?php $my_query = new WP_Query('category_name=werk&posts_per_page=3');
               while ($my_query->have_posts()) : $my_query->the_post();
               $do_not_duplicate = $post->ID;?>
               <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><img src="<?php echo get_post_meta($post->ID, 'slider-image', true); ?>" alt="" title="<?php the_title(); ?>" /></a>
               <?php endwhile; ?>
             </div> <!-- END slider -->
    
             <br clear="all" />
    
            <?php if (have_posts()) : while (have_posts()) : the_post();
            if( $post->ID == $do_not_duplicate ) continue; ?>
              <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
    
            <!-- Do stuff... -->
    
            <?php endwhile; endif; ?>
    
        </div> <!-- end main-content-werk -->
  2. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    You're running two separate Loops.

    Try adding a wp_reset_query() between them?

  3. kortschot
    Member
    Posted 3 years ago #

    yeah I did, thought it was still in there, not workin either. I used the codex page for multiple loops.

    here's the full code of the page.

    http://pastebin.com/Wsf4g3Z1

  4. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    Do you need to globalize $do_not_duplicate?

    You might try one of the other forums, e.g. WP-Advanced. You might have better luck having someone with more expertise with multiple Loops see/answer your question?

  5. kortschot
    Member
    Posted 3 years ago #

    Thanks for the advice, ill check it out.
    The forum is closed though.. only moderators can paste threads there.

  6. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    Strange. I don't know what better forum to suggest, then. Maybe "How-To and Troubleshooting", or "Plugins and Hacks"?

  7. kortschot
    Member
    Posted 3 years ago #

    Thanks, ill repost it.

  8. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    http://pastebin.com/uH5UG154

    no guarantee ;-)

  9. kortschot
    Member
    Posted 3 years ago #

    wht do you mean...

    edit: oh =)

    ill check it out

  10. kortschot
    Member
    Posted 3 years ago #

    oh dude!

    If you where a girl!

    thanks a bunch m8! works like a charm!

  11. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    If you where a girl!

    no chance - no flowers please - i prefer a drink ;-)

  12. kortschot
    Member
    Posted 3 years ago #

    beer it is =)

Topic Closed

This topic has been closed to new replies.

About this Topic