Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I would like to create a page that will show all the posts from one particular category. I want to show the post title with the post thumbnail and content and nothing else ..no other meta ..no post date, no author, no excerpt , nothing I have tried to follow various answers/tutorials without success leading me to feel somewhat confused. Do I create a loop-category.php and add an if-category() statement for that category?? If so what statement please ?? please could someone explain clearly step by step Thank You

share|improve this question
    
Your question is a little confusing, do you want this list of category posts on a special/specific page or are you just wanting to get control over the post listing on a native category archive, eg. example.com/category/some-category ? –  t31os Mar 9 '11 at 13:52

1 Answer 1

You don’t new »statements«. Take a look at the Template Hierarchy: WP does most of the work for you.

1. Find the name

Just create a new post list template, similar to your index.php and name it category-slug.php.

To get the slug part, go to wp-admin/edit-tags.php?taxonomy=category and look at the column named … slug.

Screenshot
See the full size image

In my example image the slug for the category Cat A is cata, so your template’s name has to be category-cata.php.

2. Write the template

That is even easier: Include your usual suspects (header, sidebar, footer) and put a very basic loop inside.

Sample code

<?php # -*- coding: utf-8 -*-
get_header();
get_sidebar();
?>
<h1><?php wp_title(); ?></h1>
<ul class="postlist">
<?php
while ( have_posts() )
{
    the_post();
    ?>
    <li <?php post_class(); ?>><h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    <?php
    the_post_thumbnail();
    // If you need the full content, use
    // the_content();
    // wp_link_pages();
    the_excerpt();
    ?>
    </li>
    <?php
}
echo get_previous_posts_link(), get_next_posts_link();
?>
</ul>
<?php
get_footer();

WordPress will choose the template automagically, you have nothing more to do.

3. Style the template

In your theme’s header the element body or the element html (if you use HTML5 already) should have a call to body_class():

<body <?php body_class(); ?>>

or

<html lang="<?php bloginfo('language'); ?>" <?php body_class(); ?>>

Make sure your theme has it. On your new category archive the class attribute will look very similar to this:

class="archive category category-cata category-58 logged-in admin-bar"

Note the category-cata. You may now add special rules to your stylesheet (usually style.css) to change only this page.

Sample code

body.archive.category-cata
{
    background: #345;
    color:      #fff;
}
/* The thumbnails */
body.archive.category-cata .attachment-post-thumbnail
{
    float:      left;
    margin:     0 10px 10px 0;

}

 
 
 
And that’s all.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.