Multiple loop: problem with $post
-
I have a problem with multiple loops inside my custom template:
<?php get_header(); $my_query = new WP_Query('showposts='.$slide_count.'&cat=5'); while ($my_query->have_posts()) : $my_query->the_post(); //do something endwhile; $category_content = get_post_meta($post->ID, 'category_content', true); $my_query = new WP_Query('orderby=ID&order=ASC&cat='.$category_content); while ($my_query->have_posts()) : $my_query->the_post(); ?> <h2><?php the_title() ?></h2> <?php the_content() ?> <?php endwhile; get_footer(); ?>
The above is a example of it. After the first while I try to access the property $post->ID in the get_post_meta. I would like the ID of the page I’m showing – but I get the last ID from the above loop. How can I prevent the loops from overwriting the loop that WordPress generates?
Please tell me, if you do not understand my problem. I think is a bit complicated to explain ??
Thanks!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Multiple loop: problem with $post’ is closed to new replies.