0

I'm an experienced php programmer, but a wordpress newbie. My site uses the theme twenty eleven. I have created some post categories, and some posts for each category. On my site, for each post category, a page has automatically been created displaying the posts for that category. So far so good.

What I would like to do now is do some customization. For example:

  1. For some categories, I want the full content displayed, but for others, just the synopsis.
  2. For some categories, I want the page to have a link to the permalink of the posts being displayed, but for others not.
  3. For some categories, I wish to display the post's featured image, but for others not.

Etc.

How do I accomplish this?

I'm aware of the various php files, such as header.php, etc. It appears that the file that handles category pages is category.php and inside it is a loop "while ( have_posts() )". Is there one php file that I'm supposed to edit and customize to accomplish what I need? (Maybe content.php?) Or is different from this? I would be grateful for any assistance.

3

One way to do it is with the WordPress Template Hierarchy. If your category names/slugs are not likely to change you can have a separate template for each category. For example:

category-books.php // will be loaded when viewing 'Books' category
category-magazines-and-newspapers.php // will load for 'Magazines and Newspapers' category

This way you can customize each category view as much as you'd like.

As for content.php, it's just a way to abstract the logic (of displaying an individual article) and to use it in many different places by simply including it on the page (with the help of get_template_part function). You can always customize this template portion as well by creating content-books.php, content-magazines.php and including them in your various templates.

  • Thank you. Creating a series of mycat.php pages sounds good. But is there some "hello world" starter template or file out there that I could use to help me create my first mycat.php file? – oyvey May 22 '13 at 15:09
  • You can start off with the code inside category.php and (in case of your #2 and #3) content.php which is included inside category.php. – montrealist May 22 '13 at 15:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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