Display one category in one page

I have different categories called as reviews, ideas etc. I have a page called as review, I want to display review category to the review page (only review category). Is this possible? Which file I have to change? I have the code below, but it is displaying only the texts not any links to the posts, 7 is my category id.

if( is_page( 'reviews' )){

         query_posts("cat=7" ); 


Answers 2

  • From what I understand, the question is, how can you show only one category on a WordPress Page?

    What Scuba Kay is suggesting is the default category archive, if you want to go that route, WordPress already has archive pages with your posts for each category without you having to create your own Page. If you want to make changes to this archive page, you can read up on Category Templates. This will enable you to create your own template for a specific category.

    If you literally want to create a WordPress Page and just call posts from a category, you can create a Page Template and use a Query similar to what you're already doing and create your own Loop. There's another good question on this site that explains how to pull posts using the Codex as reference.

    So for example, if you're using get_posts to call a reviews category on a Page Template, it might look something like this:

            $reviewArgs = array( 
                'category' => '3', 
                'posts_per_page' => 5
            $reviews = get_posts( $reviewArgs );
            foreach ($reviews as $post) :  setup_postdata($post); 

    Hope that helps!

Related Questions