Results 1 to 4 of 4

Thread: Loop within a Loop using Custom Taxonomy

  1. #1
    Mild Fuzz is offline Here For The Peanuts
    Join Date
    Feb 2010
    Posts
    106

    Default Loop within a Loop using Custom Taxonomy

    In WP3 RC I am trying to link different post types using taxonomy

    I need to call a secondary loop within the main loop, the secondary loop basing it's query on the taxonomy of the parent post it is within.

    Trouble I am having is that I can't get the secondary loop to only display relevant content, it just shows ALL of the posts in that type. Here the code of the secondary loop

    PHP Code:
    <?php
                
    /*Internal Loop
                --------------*/
                
                
    $taxonomies=get_the_term_list($post->ID,'Partners','','','');
            
                
    $taxonomies explode('>',$taxonomies);
                
                
    $taxonomies $taxonomies[1];
                
            
                
    $people = new WP_Query('post_type=People&Partners='.$taxonomies);?>            
                <?php if ($people->have_posts()) : while ($people->have_posts()) : $people->the_post(); ?>
                <?php the_title();?>
                <?php the_content();?>
                <?php endwhile; else:?>
                <?php endif;?>
                <?php
                
    /*--------------
                Internal Loop*/
    ?>

  2. #2
    Mild Fuzz is offline Here For The Peanuts
    Join Date
    Feb 2010
    Posts
    106

    Default

    fixed it

    Code:
    $people = new WP_Query('post_type=People&Partners='.$taxonomies);?>
    becomes:

    Code:
    $people = new WP_Query('post_type=People&partners='.$taxonomies);?>

  3. #3
    ethanshaw is offline Hello World
    Join Date
    Feb 2010
    Posts
    8

    Default

    I 'm trying to use this snippet in WP 3.1 and am getting this error: Warning: explode() expects parameter 2 to be string, object given in ***** on line 33. Any thoughts on what could be wrong? I have been looking for a solution to this for a really long time, I'm so happy I finally found one!

  4. #4
    Mild Fuzz is offline Here For The Peanuts
    Join Date
    Feb 2010
    Posts
    106

    Default

    I assume you've edited the code to suit your purpose, have you tried var_dump($taxonomies) before the explode to see its value?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •