query_posts returns pages
-
Hi there,
In my website, I have an activities-page. On this page, the content of the ‘activities’-page is displayed first, followed by all posts (which contain the actual events) below. To make users select which categories of posts they’d like to show, I’d like to add categories to the ‘activities’-page (using this plugin) which works great.
Displaying these posts/events, however, gives some difficulties. Below is the code I’m using. $categories is an array with the categories that need to be displayed, $main_id is the ID of the activities-page.
<?php for($i = 0; $i < count($categories); $i++){ ?> <div class="activiteiten"> <?php $post_array = query_posts(array('post_per_page' => '-1', 'post_type' => 'post', 'category_name' => $categories[$i], 'exclude' => $main_id, 'post_status' => 'publish')); echo "<h1>". $categories[$i] ."</h1>"; if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="activiteit"> <h2><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2> <div class="activiteitinfo"> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> <?php if ( has_post_thumbnail()) : the_post_thumbnail(); else : ?> <img src="<?php bloginfo('template_directory'); ?>/img/no-thumbnail.png" width="110px" class="" /> <?php endif; ?> </a> <?php the_excerpt(); ?> <p class="meer"><a href="<?php the_permalink(); ?>">Lees verder »</a></p> </div><!-- /.activiteitinfo --> </div><!-- /.activiteit --> <?php endwhile; ?> <?php else : ?> <p>Op dit moment zijn er geen activiteiten in deze categorie gepland.</p> <?php endif; ?> </div> <?php } ?>The problem is in the query_posts-function. If I add the ‘category_name’-parameter, the ‘post-type’- and ‘exclude’-parameters are neglected.
Thanks a lot for any help and tips,
Bramhttp://ww.wp.xz.cn/extend/plugins/post-tags-and-categories-for-pages/
The topic ‘query_posts returns pages’ is closed to new replies.