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 am trying to create a custom template that can give the following effect...

  • Category Name A (with image)

    • post with category name A
    • post 2 with category name A
    • post 3 with category name A
  • Category Name B (with image)

    • post with category name B
    • post 2 with category name B
    • post 3 with category name B

Should I do this with custom post types? If so, do I have create two, or can I manage this with one custom post type?

share|improve this question

1 Answer 1

I am not sure I understand exactly the problem, but If I do - there is absolutely no need for a custom post type.

all you have to do is use multiple loops and basically divide the query into sub-loops for each category .

<div id="cat-1">
     <?php query_posts('cat=1&posts_per_page=5');// put relevant category and number of posts
         if (have_posts()) : while (have_posts()) : the_post();
         // Do whatever ...
     endwhile; endif; reset_query();?>

</div>

<div id="cat-2">
     <?php query_posts('cat=2&posts_per_page=1');// put relevant category and number of posts
          if (have_posts()) : while (have_posts()) : the_post();
          // Do whatever ..
     endwhile; endif; reset_query(); ?>
</div>

<div id="cat-3">
     <?php query_posts('cat=3&posts_per_page=-1');// put relevant category and number of posts
          if (have_posts()) : while (have_posts()) : the_post();
          // Do whatever ..
     endwhile; endif; reset_query();?>
</div>..etc.. etc..

Note that you can do the same using Loops with query_posts() , Loops with WP_Query() or Loops with get_posts().

regarding the image - I am not sure what Image you want - but if you refer to a category image (special image assigned to categories) you will need to use some plugin like these ..

share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.