I have written some basic PHP to get the Permalink and title of any post within a certain category. This was written for the footer and works just fine.
My issue is now when I try to use the same code within an if loop, it fails.
What should I be doing differently?
Here is my code:
<?php if (in_category('training'))
{
<?php query_posts('category_name=training'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; endif; ?>
}
elseif (in_category('club'))
{
<?php query_posts('category_name=club'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; endif; ?>
}
else
{
echo "Nothing to show";
}
?>
1 comment