<?php wp_list_categories(‘orderby=name&include=2’); ?>
This code example comes from this help page:
Category Help
Does this help with your problem?
It displays the categories, but not the post “in” the category. So the category id is 34, how do I display the posts from id 34 into the sidebar?
There is probably an easier way, or a plugin, but here is how I accomplished showing a link to each category post, limited by category:
<?php
$myposts = get_posts(‘numberposts=10&category=’);
foreach($myposts as $post) :
setup_postdata($post);
?>
<?php if ( ! in_category(6) ) { ?>
<li class=’page_item’>” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”><?php the_title(); ?>
<?php } ?>
<?php endforeach; ?>
Just change the in_category(6) to include whatever category you wish to have post links displayed from.
Thank you…
When adding a link what php tag do I put in here to link to the post?
🙂
<ul>
<li class="page_item"><h2>Recent News</h2></li>
<?php
$myposts = get_posts('numberposts=10&category=');
foreach($myposts as $post) :
setup_postdata($post);
?>
<?php if ( ! in_category(6) ) { ?>
<li class='page_item'><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></li>
<?php } ?>
<?php endforeach; ?>
</ul>
For some reason, the earlier message truncated the a href tag. The code above should display a link to the post using the Title as the link text.
Ah… thank you so much!
Actually I had to add the category # to display the correct category posts:
$myposts = get_posts(‘numberposts=10&category=28’);
Thanks for the help 🙂
Glad I could help. You are quite welcome!
This may be six of one, half a dozen of the other, but here’s how I did it. You can see it (Tech Tips), here: http://www.znzx.com
You’ll need to grab your category ID (I inserted the value X), and you can tell it how many posts you want it to display (value Y). Change up the heading from techtips to whatever your category is.
<li id="techtips"><h3>Tech Tips</h3>
<ul>
<?php
global $post;
$myposts = get_posts('numberposts=Y&offset=1&category=X');
foreach($myposts as $post) :
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>
@jonimueller: Thanks for your post.