Studio Theme - I would like to create a Category index on a Page.

I am trying to create a page that indexes a group of categories. Example I have a category of Recipes, with many sub-cats and want to have a page that allows a visitor to click on the category of their choice which opens up a page that lists the feature image and short description of posts in that category.

I thought I could create a template for a page and do something like this:
$cat_title = single_cat_title('display'=>false);
// THE LOOP ...
echo $cat_title;
But I don't know which template or php file to use as a master.

anyone help?

  • Tammie
    • WordPress Wizard

    @bkeller99: Ok so I'm on the right page lets clarify:

    You want a template page to show a particular category? Assuming you are going to know this category you can simply use a cat variable to query_posts and a template creation.

    First up create a page template. Here is a tutorial on that:

    Next we need to think about how Studio uses loops. It has all it's loops in library/functions/loop-functions.php so you'd need to take one of those out and put it into the template. A good example would be the archive one.

    It also all depends on if you want one of more categories... I'd take a look at this:

    how One Category by ID

    Display posts from only one category ID (and any children of that category):


    Show One Category by Name

    Display posts from only one category by name:

    query_posts('category_name=Staff Home');

    Show Several Categories by ID

    Display posts from several specific category IDs:


    Exclude Posts Belonging to Only One Category

    Show all posts except those from a category by prefixing its ID with a '-' (minus) sign.


    This excludes any post that belongs to category 3.

    Multiple Category Handling

    Display posts that are in multiple categories. This shows posts that are in both categories 2 and 6:

    query_posts(array('category__and' => array(2,6)));

    To display posts from either category 2 OR 6, you could use cat as mentioned above, or by using category__in (note this does not show posts from any children of these categories):

    query_posts(array('category__in' => array(2,6)));

    You can also exclude multiple categories this way:

    query_posts(array('category__not_in' => array(2,6)));

    If this is totally on wrong track though let me know.

  • bkeller99
    • Site Builder, Child of Zeus

    thanks Tammie,
    One point of confusion is that all of the examples don't use the wpmu loop. So what I am understanding is the the query needs to go before the loop, say after the #blog-page ---> statement (using page.php in the studio theme as the master page.)
    Then I would place what ever styling after the loop, so after <?php wpmu_pageloop(); ?>
    Is that correct?

  • Tammie
    • WordPress Wizard

    @bkeller99: What I was referring to was you'd need to take out the loop as those loops won't work. You can of course make a new loop function but perhaps easier is in your template to create your own loop by taking:

    $page = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("cat=&showposts=5&paged=$page"); while ( have_posts() ) : the_post();?>
    <div class="post" id="post-<?php the_ID(); ?>">
    <div class="post-content-wp">
    <h2 class="posttitle">" rel="bookmark" title="<?php _e( 'Permanent Link to', TEMPLATE_DOMAIN ) ?> <?php the_title_attribute(); ?>"><?php the_title(); ?></h2>
    <p class="date"><span class="byline"><?php the_time('M j Y') ?> <?php _e( 'in', TEMPLATE_DOMAIN ) ?> <?php the_category(', ') ?> <?php _e( 'by ', TEMPLATE_DOMAIN ) ?><?php the_author_link(); ?></span></p>
    <div class="entry">
    <?php if(function_exists('the_post_thumbnail')) { ?><?php if(get_the_post_thumbnail() != "") { ?><div class="alignleft">
    <?php the_post_thumbnail(); ?></div><?php } } ?>

    <?php the_excerpt(); ?>
    <p class="postmetadata"><span class="tags"><?php the_tags( __( 'Tags: ', TEMPLATE_DOMAIN ), ', ', '
    '); ?></span> <span class="comments"><?php comments_popup_link( __( 'No Comments »', TEMPLATE_DOMAIN ), __( '1 Comment »', TEMPLATE_DOMAIN ), __( '% Comments »', TEMPLATE_DOMAIN ) ); ?></span></p>
    <?php endwhile;

    For instance from the blogpage_loop. You can read more about loops here:

    As you can see there are a few different ways in that link which may be great for you to explore since 3.0.

  • bkeller99
    • Site Builder, Child of Zeus

    You got me the right stuff.
    one final question and I'll leave you alone.
    These two statements do the trick.

      <?php wp_list_categories('include=3&title_li=<h2 class="teal">' . __('Recipe Index') . '</h2>' ); ?>
      <?php wp_list_categories('orderby=id&show_count=1&use_desc_for_title=0&child_of=3'); ?>

    Which produces this for me:

    However, On the codex page it doesn't show how to combine arguments.How do I get rid of the

  • styling for the Recipe Index name. I don't see how to say styling=none for that label.
    Almost there.
  • Tammie
    • WordPress Wizard

    @bkeller99: It's because you are using list_categories so it's creating a list by default this should give you a clue:

    (string) Style to display the categories list in. A value of list displays the categories as list items while none generates no special display method (the list items are separated by
    tags). The default setting is list (creates list items for an unordered list). See the markup section for more. Valid values:

    * list - Default
    * none

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.