$my_query = new WP_Query(‘cat=10&showposts=5’)
-
I am using Glider in a project for a client – see here: https://intunedonline.com.netfirms.com/. This involves using multipe posts multiple loops. Please find below the codes
This is used to display 5 featured posts
<?php $count = 1 ?> <?php $my_query = new WP_Query('category_name=featured&showposts=5'); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate[$post->ID] = $post->ID; ?> <?php echo $count; ?> <?php $count = $count + 1 ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a> <?php the_excerpt() ?> <?php endwhile; ?>
This is used to display 5 anchor links to the firs 5 featured posts based on the id
<?php $count = 1 ?> <?php $my_query = new WP_Query('category_name=featured&showposts=5'); while ($my_query->have_posts()) : $my_query->the_post(); ?> <li><a href="#section<?php the_ID(); ?>" rel="nofollow"><?php echo $count; ?></a></li> <?php $count = $count + 1 ?> <?php endwhile; ?>
This is the normal loop that must (BUT DOES NOT) display the other posts expect the above ones.
<?php if (have_posts()) : while (have_posts()) : the_post(); if( $post->ID == $do_not_duplicate[$post->ID] ) continue; ?> <div class="<?php echo $odd_or_even; ?>" id="post-<?php the_ID(); ?>"> <?php $odd_or_even = ('odd'==$odd_or_even) ? 'even' : 'odd'; ?> <div class="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></div> <?php the_excerpt(); ?> </div> <?php endwhile; endif; ?>
The problem is that this does not continue showing the rest of the posts. It just goes on showing only 4 posts.
How do I have to alter the code so that I have 10 other posts displayed in the home page?
Thanks very much!
Baki
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘$my_query = new WP_Query(‘cat=10&showposts=5’)’ is closed to new replies.