I am stuck here, though that doesnt say much, I know squat about PHP for how long I have been trying to learn, but anyway I need some help with some conditional code for a WordPress theme, but first let me explain.
Ok so I have a WP site up that uses a different template file for one specific category and single "a reviews area to be exact. Now I have a list of the 5 latest posts from each category on the site which works pretty decent, though I would like to show different latest posts from the reviews section in the footer, so throughout the whole site all the links in the footer remain the same sitewide, though I would like to show something different in the reviews section, so this is what I have now that works in the footer;
This works excelent and displays the 5 latest from each category, now I want to set something up so that if in category #x it will show this data..
Ok so I have a WP site up that uses a different template file for one specific category and single "a reviews area to be exact. Now I have a list of the 5 latest posts from each category on the site which works pretty decent, though I would like to show different latest posts from the reviews section in the footer, so throughout the whole site all the links in the footer remain the same sitewide, though I would like to show something different in the reviews section, so this is what I have now that works in the footer;
Code:
<?php
$lastposts = get_posts('numberposts=5&category=1');
foreach ($lastposts as $post) :
setup_postdata($posts);
?>
<li> <a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?> </a></li>
<?php endforeach; ?>
</ul>
<ul class="latest-footer">
<li><strong>Metal Detecting Talk</strong></li>
<?php
$lastposts = get_posts('numberposts=5&category=6');
foreach ($lastposts as $post) :
setup_postdata($posts);
?>
<li> <a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?> </a></li>
<?php endforeach; ?>
</ul>
<ul class="latest-footer">
<li><strong>Metal Detecting Articles</strong></li>
<?php
$lastposts = get_posts('numberposts=5&category=7');
foreach ($lastposts as $post) :
setup_postdata($posts);
?>
<li> <a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?> </a></li>
<?php endforeach; ?>
</ul>
<ul class="latest-footer">
<li><strong>Metal Detector Reviews</strong></li>
<?php
$lastposts = get_posts('numberposts=5&category=4');
foreach ($lastposts as $post) :
setup_postdata($posts);
?>
<li> <a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?> </a></li>
<?php endforeach; ?>
</ul>
<br style="clear:both;" />
<ul class="latest-footer">
<li><strong>Metal Detecting Stories</strong></li>
<?php
$lastposts = get_posts('numberposts=5&category=5');
foreach ($lastposts as $post) :
setup_postdata($posts);
?>
<li> <a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?> </a></li>
<?php endforeach; ?>
</ul>
<ul class="latest-footer">
<li><strong>Metal Detecting Finds</strong></li>
<?php
$lastposts = get_posts('numberposts=5&category=3');
foreach ($lastposts as $post) :
setup_postdata($posts);
?>
<li> <a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?> </a></li>
<?php endforeach; ?>
</ul>
<ul class="latest-footer">
<li><strong>Detecting & Treasure News</strong></li>
<?php
$lastposts = get_posts('numberposts=5&category=8');
foreach ($lastposts as $post) :
setup_postdata($posts);
?>
<li> <a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?> </a></li>
<?php endforeach; ?>
</ul>
<ul class="latest-footer">
<li><strong>Detecting Research</strong></li>
<?php
$lastposts = get_posts('numberposts=5&category=9');
foreach ($lastposts as $post) :
setup_postdata($posts);
?>
<li> <a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?> </a></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
Code:
<?php if ( in_category('4') ) : ?>
<div id="more-detector-reviews">
<?php if ( in_category('14') ): ?>
<li><strong>More Whites Metal Detectors</strong></li>
<?php
$lastposts = get_posts('category=14');
foreach ($lastposts as $post) :
setup_postdata($posts);
?>
<li> <a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?> </a></li>
<?php endforeach; ?>
<?php endif; ?>
</div>
<div id="more-detector-reviews">
<?php if ( in_category('10') ): ?>
<li><strong>More Fisher Metal Detectors</strong></li>
<?php
$lastposts = get_posts('category=10');
foreach ($lastposts as $post) :
setup_postdata($posts);
?>
<li> <a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?> </a></li>
<?php endforeach; ?>
<?php endif; ?>
</div>
</div>
<div id="more-detector-reviews">
<?php if ( in_category('12') ): ?>
<li><strong>More Bounty Hunter Metal Detectors</strong></li>
<?php
$lastposts = get_posts('category=12');
foreach ($lastposts as $post) :
setup_postdata($posts);
?>
<li> <a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?> </a></li>
<?php endforeach; ?>
<?php endif; ?>
</div>
</div>
<div id="more-detector-reviews">
<?php if ( in_category('13') ): ?>
<li><strong>More Garrett Metal Detectors</strong></li>
<?php
$lastposts = get_posts('category=13');
foreach ($lastposts as $post) :
setup_postdata($posts);
?>
<li> <a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?> </a></li>
<?php endforeach; ?>
<?php endif; ?>
</div>
</div>
<div id="more-detector-reviews">
<?php if ( in_category('11') ): ?>
<li><strong>More Minelab Metal Detectors</strong></li>
<?php
$lastposts = get_posts('category=11');
foreach ($lastposts as $post) :
setup_postdata($posts);
?>
<li> <a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?> </a></li>
<?php endforeach; ?>
<?php endif; ?>
</div>
</div>
<div id="more-detector-reviews">
<?php if ( in_category('15') ): ?>
<li><strong>More Tesoro Metal Detectors</strong></li>
<?php
$lastposts = get_posts('category=15');
foreach ($lastposts as $post) :
setup_postdata($posts);
?>
<li> <a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?> </a></li>
<?php endforeach; ?>
<?php endif; ?>
</div>
</div>
<div id="more-detector-reviews">
<?php if ( in_category('16') ): ?>
<li><strong>More Troy Metal Detectors</strong></li>
<?php
$lastposts = get_posts('category=16');
foreach ($lastposts as $post) :
setup_postdata($posts);
?>
<li> <a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?> </a></li>
<?php endforeach; ?>
<?php endif; ?>
</div>
</div>
<div id="more-detector-reviews">
<?php if ( in_category('10') ): ?>
<li><strong>More Fisher Metal Detectors</strong></li>
<?php
$lastposts = get_posts('category=10');
foreach ($lastposts as $post) :
setup_postdata($posts);
?>
<li> <a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?> </a></li>
<?php endforeach; ?>
<?php endif; ?>
</div>