views:

23

answers:

1

Hi all,

I have a page in Wordpress that displays posts with a category of "newspaper" only. Now, The posts are ordered by descending order (I think, if that is the default), such that the newest is at the top.

This is the code that I have:

<?php $my_query = new WP_Query('category_name=newspaper&posts_per_page=-1'); ?>

<?php if (have_posts()) : while ($my_query->have_posts()) : $my_query->the_post(); ?>
<div class="post">
<!--<h3><?php the_title(); ?></h3>-->
<?php the_content('Read the rest of this entry &raquo;'); ?>
<div class="clear"></div>
</div>
<?php endwhile; endif;?>

I was wondering if it's possible to show posts with a "featured" tag at the top, while all other posts without a featured tag afterward.

Thanks! Amit

A: 

Okay this is what I temporarily did. I didn't rely on a featured tag, but rather on a featured-newspaper category. It's not exactly how I wanted it to be, but this will do for now:

<?php $my_query = new WP_Query('category_name=newspaper&posts_per_page=-1'); ?>
<?php $my_featured = new WP_Query('category_name=featured-newspaper&posts_per_page=-1'); ?>

<!-- featured posts -->
<?php if (have_posts()) : while ($my_featured->have_posts()) : $my_featured->the_post(); ?>
<div class="post">
    <!--<h3><?php the_title(); ?></h3>-->
    <?php the_content('Read the rest of this entry &raquo;'); ?>
    <div class="clear"></div>
</div>
<?php endwhile; endif;?>
<!-- /end featured -->


<?php if (have_posts()) : while ($my_query->have_posts()) : $my_query->the_post(); ?>
<div class="post">
    <!--<h3><?php the_title(); ?></h3>-->
    <?php the_content('Read the rest of this entry &raquo;'); ?>
    <div class="clear"></div>
</div>
<?php endwhile; endif;?>

Like I said, it's not the cleanest way to do things, but it works. If you have other suggestions, I'm all ears :)

Thanks! Amit

Amit