-1

I've got a custom post type that I would like to be able to show in the following:

is this possible using the following code:

<?php query_posts(array('post_type' => 'story', 'orderby' => 'title', 'order' => 'asc', 'post_status' => 'publish', 'paged' => $paged)); ?>

<?php if ( have_posts() ) : ?>
 <?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>

<hgroup>
<h3 class="odd-title">
  <?php the_title(); ?>
</h3>
</hgroup>
<div id="odd-story">
<div class="success-file">
  <?php the_post_thumbnail(184, 260); ?>
</div>
<div class="odd-content">
<?php the_content(); ?>
<p><?php the_tags(); ?></p>
</div>
</div>

0

I recomend use query_posts() functon only when you really need it and when you really know what your are doing. In your case, as you are going to make a, I think, secondary loop, It is definitely better use other alternatives like a new WP_Query() object. More info the description part of query_posts() documentation. Also, for future questions please dont' say "I want to do this with this code", it is a clear XY problem.

So, here an example of how you can do what your are trying. In your loop:

<?php if ( have_posts() ) : ?>
    <?php $j = 0; ?>
    <?php while ( have_posts() ) : the_post(); ?>
        <?php $class= (++$j % 2 == 0) ? 'even' : 'odd'; ?>
        <hgroup>
            <h3 class="<?php echo $class; ?>-title">
                <?php the_title(); ?>
            </h3>
         </hgroup>
         <div id="<?php echo $class; ?>-story">
             <div class="success-file">
                 <?php the_post_thumbnail(184, 260); ?>
             </div>
             <div class="<?php echo $class; ?>-content">
                 <?php the_content(); ?>
                 <p><?php the_tags(); ?></p>
             </div>
         </div>
     <?php endwhile; ?>
<?php endif; ?>

Not the answer you're looking for? Browse other questions tagged or ask your own question.