Try:
<?php $class = 'posn';
$c = 0;?>
<?php if (have_posts()) : while (have_posts()) : the_post();
$c++;
$class .= $c;
?>
<div id="post-<?php the_ID(); ?>" class="post <?php echo $class; ?>"
That should give you unique classes on an unlimited number of posts (posn1, posn2 etc)
I will give this a try – thanks so much for your prompt response!
~Deirdre
Hi Esmi –
Thanks again for your help =)
I am getting a syntax error when I use the above code, though.
I tried adding a “>” at the end of this line:
<div id="post-<?php the_ID(); ?>" class="post <?php echo $class; ?>"
But still received an error.
Here is the full index.php file with the code inserted:
<?php
/**
* @package WordPress
* @subpackage Classic_Theme
*/
get_header();
?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_date('','<h2>','</h2>'); ?>
<?php $class = 'posn';
$c = 0;?>
<?php if (have_posts()) : while (have_posts()) : the_post();
$c++;
$class .= $c;
?>
<div id="post-<?php the_ID(); ?>" class="post <?php echo $class; ?>">
<h3 class="storytitle"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
<div class="meta"><?php _e("Filed under:"); ?> <?php the_category(',') ?> — <?php the_tags(__('Tags: '), ', ', ' — '); ?> <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></div>
<div class="storycontent">
<?php the_content(__('(more...)')); ?>
</div>
<div class="feedback">
<?php wp_link_pages(); ?>
<?php comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)')); ?>
</div>
</div>
<?php comments_template(); // Get wp-comments.php template ?>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
<?php posts_nav_link(' — ', __('« Newer Posts'), __('Older Posts »')); ?>
<?php get_footer(); ?>
What error are you getting?
This is the error:
Parse error: syntax error, unexpected $end in /hermes/bosweb/web032/b325/sl.alluramo/public_html/hideoutmagazine/HideOutMag2010/wp-content/themes/HideoutRetro/index.php on line 43
You’ve got a repeated line from when you added the new code in. Change:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_date('','<h2>','</h2>'); ?>
<?php $class = 'posn';
$c = 0;?>
<?php if (have_posts()) : while (have_posts()) : the_post();
$c++;
$class .= $c;
?>
<div id="post-<?php the_ID(); ?>" class="post <?php echo $class; ?>">
to:
<?php $class = 'posn';
$c = 0;?>
<?php if (have_posts()) : while (have_posts()) : the_post();
$c++;
$class .= $c;
?>
<?php the_date('','<h2>','</h2>'); ?>
<div id="post-<?php the_ID(); ?>" class="post <?php echo $class; ?>">
Oh! I see. I made the correction. Thank you — it is working just as you said.
If you are ever in Portland, OR, I’ll make you dinner.
=)
Thanks!
Deirdre