WORDPRESS 3.0+
I wanted to display the recent post titles from a specific category, to visitors who landed on a post within that specific category (and i didn’t want to use a plugin).
List posts from a specific category ONLY on pages within specified category:
php if (in_category('32')) { ?><div class="moduletable"><h3>Latest Snippets</h3><ol>phpglobal $post;$myposts = get_posts('numberposts=5&order=DESC&orderby=post_date&category=32');foreach($myposts as $post) :setup_postdata($post);?>php endforeach; ?></ol></div>php }else { ?>php } ?>NOTE – I’ve bolded
- 5 (number of posts to display) and
- 32 – the category ID
Theses are the items I used in the example :)
RELATED ARTICLES
- The Best WordPress SEO Plugin
- Advice – Nofollow Blog Comments
- Do WordPress Self Pings Waste Pagerank?
- Host WordPress blog in a subdomain or directory?
- How To Exclude A Category or Post From RSS Feed in WordPress
- List Recent Posts From Single Category on Posts Within Same Category
- Add Text To Home Page Only on WordPress Blog
- WordPress Contact Form 7 Redirect To Thank You Page
- Speed Up Contact Form 7 Plugin For WordPress
- Dynamic PHP Copyright Notice in WordPress
- How To Import Large WordPress XML File Above Default Limit Size



