Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm working on a theme and i use dimox's breadcrumbs to display breadcrumbs in the footer, so far so good, works almost flawlessly

BUT

there's one template file where i use 2 loops and i'm guessing this is what screws with the breadcrumbs... but i couldn't put my finger on it exactly...

here's the code:

<div class="span-24">



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

<?php $parent_title = $post->post_title; ?>
<?php $parent_content = $post->post_content; ?>
<?php $parent = $post->ID; ?>

<?php endwhile; else : ?>
<?php endif; ?>


<div id="preview">
    <img id="previewImg" src="<?php bloginfo("template_url"); ?>/images/spacer.png" alt="" />
</div>

<h1><?php echo $parent_title; ?></h1>

<div class="proj_list">     
    <ul id="previewUL">
    <?php query_posts('posts_per_page=15&post_type=page&post_parent='.$parent); while (have_posts()) : the_post(); ?>   
    <?php $image_thumb = get_post_meta($post->ID, 'image-thumb', true); ?>
    <li><a href="<?php the_permalink(); ?>" rel="<?php $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), medium, false, '' ); echo $src[0]; ?>"><?php the_title(); ?></a></li>
    <?php endwhile; ?>
    </ul>
</div>

<div class="">  
    <?php print($parent_content);?>
</div>

<script  type="text/javascript">
jQuery(document).ready(function() {
    jQuery('img#previewImg').animate({opacity: 0}, 0 );
    jQuery('#previewUL li a').each(
        function( intIndex ){

        jQuery(this).hover(
            function(){
                var imgurl = jQuery(this).attr('rel');
                jQuery('img#previewImg').attr('src', imgurl);
                jQuery('img#previewImg').clearQueue();
                jQuery('img#previewImg').animate({opacity: 0}, 0 );
                jQuery('img#previewImg').animate({opacity: 1}, 250 );
            },
            function(){
                jQuery('img#previewImg').animate({opacity: 0}, 250 );
            });

        }
    );
});
</script>

</div><!--/span-24-->

<?php get_footer(); ?>

Take a look at previewUL ...

share|improve this question
add comment

2 Answers

Try to change the second loops with this code:

<?php $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query('showposts=15&post_type=page&post_parent='.$parent); ?>

<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>

/* your content */

<?php endwhile; ?>

<?php $wp_query = null; $wp_query = $temp; ?>
share|improve this answer
    
Yay, it works! thanks a million... would you be kind and gimme a lil' explanation of what was i doing wrong and how your solution remedied that? I admit a don't fully understand that... –  talbatz Jun 11 '11 at 13:17
    
This is an alternate method to resetting the query via wp_reset_query(). In this case, the original query is dumped into a variable, a new query is generated and output, and then the original query is restored. Thus, the original query (i.e. the original data contained in the $wp_query global) will again be available when the breadcrumbs function expects it to be available. –  Chip Bennett Jul 9 '11 at 23:48
add comment

It's a long shot, but what happens if you add in a wp_reset_query() call?

share|improve this answer
    
thanks for taking the time to answer my question! can you please point out WHERE should i add the call? –  talbatz Jun 11 '11 at 13:14
    
Somewhere between the closing of the loop for your second query, and the start of the breadcrumbs output. –  Chip Bennett Jun 11 '11 at 17:59
    
Workx! awesome :-) thanks! –  talbatz Jun 12 '11 at 8:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.