When you have the category ID number in hand, you’re ready to add the <query_post> tag to your template.
Here is an example of two parameters you can use with the <query_posts> tag:
showposts=X: This parameter tells WordPress how many posts you want to display. If you want to display only three posts, enter showposts=3.
cat=X: This parameter tells WordPress that you want to pull posts from the category with this specific ID number. If the ID category is 40, enter cat=40.
Click the Editor link on the Appearance menu.
>
>
The Edit Themes page opens.
Click the template in which you want to display the content.
If you want to display content in a sidebar, for example, choose the Sidebar template: sidebar.php.
Locate the ending </ul> tag at the bottom of the template for the theme you’re using.
>
>
If you’re using the Twenty Ten theme, the ending </ul> tag is the second-to-the-last line.
Type the following code directly above the ending </ul> tag:
<?php query_posts(‘showposts=3&cat=40’); ?>
<h2>Type Your Desired Title Here</h2>
<?php if (have_posts()) : while (have_posts()) : the_
post(); ?>
<strong><a href=
rel=bookmark title=Permanent Link to
the_title_attribute(); ?>>
?></a></strong>
<?php the_excerpt();endwhile;endif; ?>
In the first line you can change the numbers to suit your specific needs. Just change 3 to whatever number of posts you’d like to display (there is no limit!), and change 40 to the specific category ID number that you want to use.
Click the Update File button.
The changes you just made are saved to the sidebar.php template.
>
dummies
Source:http://www.dummies.com/how-to/content/how-to-pull-in-specific-content-on-your-wordpress-.html
No comments:
Post a Comment