Skip to Content
WordPress® All-in-One For Dummies®
book

WordPress® All-in-One For Dummies®

by Lisa Sabin-Wilson, Cory Miller, Kevin Palmer, Andrea Rennick, Michael Torbert
April 2011
Beginner to intermediate content levelBeginner to intermediate
908 pages
22h 37m
English
For Dummies
Content preview from WordPress® All-in-One For Dummies®

Pulling in Content from a Single Category

WordPress makes it possible to pull in very specific types of content on your Web site through the <query_posts> template tag. If you place this template tag before The Loop (see Book VI), it lets you specify which category you want to pull information from. If you have a category called WordPress and you want to display the last three posts from that category — on your front page, in your blog sidebar, or somewhere else on your site — you can use this template tag.

image The <query_posts> template tag has several parameters that let you display different types of content, such as posts in specific categories and content from specific pages/posts or dates in your blog archives. The <query_posts> tag lets you pass so many variables and parameters that we just can't list all the possibilities. Instead, you can visit this page in the WordPress Codex and read about the options available with this tag: http://codex.wordpress.org/Template_Tags/query_posts.

First, you have to find the ID number for the category you want to use; then you have to tell WordPress how to display the content by using the <query_posts> tag.

Finding the category ID number

You can't easily find the unique ID number for a category unless you know where to look. To locate it, follow these steps:

  1. Click Categories in the Posts drop-down list.

    The Categories page opens.

  2. Hover your ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

WordPress® 24-Hour Trainer

WordPress® 24-Hour Trainer

George Plumley
Gaming Hacks

Gaming Hacks

Simon Carless

Publisher Resources

ISBN: 9780470877012Purchase book