Removing query_posts()
-
I’m trying to remove query_posts() following the advice here on the WordPress Codex but it’s not working for me. If I try the advice in those instructions, the first page of my blog returns only one post instead of the five that I specify.
If I only add the “pre_get_posts” to my functions.php,it works …however it is still using get_posts() …which is inefficient. I think the reason is that there is a previous call to get_posts in my index.php which I’m not replacing. That call is simply getting a list of categories. See code below …with the first and second calls to query_posts() shown in bold. I’m primarily trying to replace the second one:
<div id="middle" class="clearfloat"> <img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/category.png" class="clearfloat" alt="" /> <?php $display_categories = array(5,6,7,8,11); $i = 1; foreach ($display_categories as $category) { ?> <div id="cat-<?php echo $i; ?>" class="category"> <?php <strong>query_posts("showposts=1&cat=$category")</strong>?> <span class="cat_title"><a href="<?php echo get_category_link($category);?>"><?php single_cat_title(); ?></a></span> <a href="<?php echo get_category_link($category);?>"><?php echo category_description($category); ?></a> </div> <?php $i++; ?> <?php } ?> </div> <?php } ?> <div id="bottom" class="clearfloat"> <div id="front-list"> <?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1; <strong>query_posts("cat=-27,-28&paged=$page&posts_per_page=5");</strong> ?> <?php while (have_posts()) : the_post(); ?>
How can I make this work?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Removing query_posts()’ is closed to new replies.