I need the page below to pull from a certain category. I’m not sure how to do it…in other words when the page is pulled up it will pull all the posts from one category and that category only.
Not sure what to add or where to add it? The category is “For Sale”
http://ampmproperties.com/for-lease-orange-county
<?php
/**
* Template Name: For Sale
*
* @package WordPress
* @subpackage Twenty_Ten
* @since Twenty Ten 1.0
*/
get_header(); ?>
<div id="container">
<div class="left_sirebar">
<?php get_sidebar(); ?>
</div>
<div id="content" role="main">
<?php $args = array( 'posts_per_page' => 3 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
if ($count==1)
{
echo "<tr>";
}
echo '<td><div class="For Sale">';
echo '<div class="heading_div"><h2 class="entry-title">';
the_title();
echo '</div></h2>';
echo '<div class="entry-content">';
echo '<div class="desc">';
the_excerpt();
echo '</div>';
echo '</div></div></td>';
if($count==$number_of_columns)
{
echo "</tr>";
$count=0;
}
$count++;
endwhile;
?>
</div><!-- #content -->
</div><!-- #container -->
You need to add the category name to your arguments array:
WordPress’ documentation is quite good – whenever you need help with a function like WP_Query, look it up. Your solution was right there in the documentation: All Posts in a Category.