• Hello! I’m modifying a theme to add multiple loops on a homepage. The theme has an option that allows you to choose the category you would like to display on a certain page.

    When you select a category from the drop-down list, it registers it as the custom meta “post_id” and queries the posts from that category onto the page. The code is.

    <?php
    $category_id =  get_post_meta($post->ID, "page_id", true);
    $limit = get_option('portfolio_limit', 10);
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;				query_posts("cat=$category_id&showposts=$limit&paged=$paged");
    ?>

    On my homepage I’m displaying a slideshow from a “featured” category and then some excerpts from some pages. Those two work but the code above doesn’t repsect the category chosen – instead just lists all the recent posts. It works only if I remove the queries above.

    So i’m trying to integrate the custom field page_id from above into the code below. I’m trying to use this code to do it (I think it’s for multiple queries) but I keep getting errors.

    <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
      <!-- Do special_cat stuff... -->
    <?php endwhile; ?>

    Am doing doing something wrong? I don’t think I can figure this out..

Viewing 1 replies (of 1 total)
  • Thread Starter nemci7v

    (@nemci7v)

    Nevermind ?? I did it by adding wp_reset_query(); ad the end of queries before the last loop.

Viewing 1 replies (of 1 total)
  • The topic ‘Multiple queries/loops on 1 page’ is closed to new replies.