WordPress and Conditions

this might sound stupid to most dudes around, but, I have this code:

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php if ( in_category('123') ) { ?>
<div class="pdfbox">
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<p>&nbsp;</p>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('pdfs'); ?></a>
</div>
<?php } else { ?>
<div class="pdfbox">
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<p>&nbsp;</p>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('pdfs'); ?></a>
</div>
<?php } ?>
<?php endwhile; else: ?>
<?php endif; ?>

The thing is, how to add another category, like if is category 1 then output, HTML, if 2 the next html, if 3, so on so on..

Read More

Thanks!

Related posts

1 comment

  1. What you might be looking for here is the elseif statement…

    <?php if ( in_category('123') ) { ?>
    <div class="pdfbox">
    <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
    <p>&nbsp;</p>
    <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('pdfs'); ?></a>
    </div>
    <?php } elseif ( in_category('125') ) { ?>
    <div class="pdfbox">
    <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
    <p>&nbsp;</p>
    <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('pdfs'); ?></a>
    </div>
    <?php } ?> { ?>
    

    Hope that helps.

Comments are closed.