Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6189267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:23:31+00:00 2026-05-24T02:23:31+00:00

I need the page below to pull from a certain category. I’m not sure

  • 0

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 -->

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T02:23:32+00:00Added an answer on May 24, 2026 at 2:23 am

    You need to add the category name to your arguments array:

    $args = array('posts_per_page' => 3, 'category_name' => 'For Sale');
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create a page that will load divs from an external page
HI I wanna timeout session from client page,i tried below code but not able
In my base page I need to remove an item from the query string
I need to redirect all page requests (php, if that matters) on a specific
I am scraping a website and am trying to pull out certain elements from
Looking to pull the category ID of a specific page in WordPress that is
I'm trying to pull the contents of Div from another page of the site
I need to manually page a GridView based report, i.e. add a second page
I have a PHP page I need to limit execution access of to only
I have any number of anchor links on a page that need to execute

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.