Thread Starter
yeleek
(@yeleek)
Asked if people have done it successfully, for examples – and asked if you can have two different catagories coming on the same static page.
For different categories see the Multiple Loops at The_Loop page.
Also, be aware that in WP 2.2 you can set your frontpage from the admin panel. (which means the Codex might be a bit outdated…)
Thread Starter
yeleek
(@yeleek)
Struggling with this… Been through loads of forum articles. Given the standard mini loop (below) what do i need to add to get it to look in a specific category?
<?php
$how_many=5; //How many posts do you want to show
require_once("wp-config.php"); // Change this for your path to wp-config.php file ?>
<ol id="whats-new">
<?
$news=$wpdb->get_results("SELECT <code>ID</code>,<code>post_title</code> FROM $wpdb->posts
WHERE <code>post_status</code>= \"publish\" ORDER BY 'ID' DESC LIMIT ".$how_many);
foreach($news as $np){
printf ("
<li><a>%s</a></li>
", $np->ID,$np->post_title);
}?>
</ol>
Thanks
Thread Starter
yeleek
(@yeleek)
Ironically – found a different example and it works…
<div id="left">
<h2>Latest News</h2>
<?php $posts = get_posts( "category=3&numberposts=5" ); ?>
<?php if( $posts ) : ?>
<ul>
<?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
<li>
<a href=<?php the_permalink() ?>>
<?php the_title(); ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
<div id="right">
<h2>Latest blog</h2>
<?php $posts = get_posts( "category=4&numberposts=5" ); ?>
<?php if( $posts ) : ?>
<ul>
<?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
<li>
<a href=<?php the_permalink() ?>>
<?php the_title(); ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>