WordPress.org

Ready to get started?Download WordPress

Forums

Showing Posts from that category only (6 posts)

  1. Cregy
    Member
    Posted 7 years ago #

    Hi

    I am sure this is very simple but I can't work it out. What code do I use to show post from only that category please? I would like to post the code in the sidebar as archives.

    Many thanks.

    Rich

  2. converting2wp
    Member
    Posted 7 years ago #

    I'm sure there are other ways to do this, but I use Scott Reilly's Customizable Post Listing plugin:

    http://www.coffee2code.com/wp-plugins/

    After installing the plugin (instructions on the web site), you've got a new function that you can drop onto the sidebar to show recent posts in a specific category, which I think is what you're asking for.

    I've found it stable and very flexible -- but from the Worpress 2.1 compatibility list, a different solution is needed for 2.1 based systems.

  3. Cregy
    Member
    Posted 7 years ago #

    Hi

    Thanks for the tip for the plugin. It works and it works well. However, I am having a slight problem in that I have created a template for the category 'heritage'. That template using the plugin to display a link to the rest of the heritage posts. See:
    Heritage Page. However, when I click on a link it reverts back to the index.php template. Is this something wrong with my template? I thought that when you created a template called 'category_8.php', all posts relating to that category would revert to that template. Do I need to create a single post template for that category as well please?

    Thanks.

    Rich

  4. converting2wp
    Member
    Posted 7 years ago #

    I don't claim to be an expert in the template hierarchy, but the "category_*.php" is used when displaying a category, i.e. the page that you get when the URL is something like

    your_wordpress_address/category/some-category

    When you click a link from the list of articles in the category, that takes you to a post which will be displayed in the format defined by single.php (if it exists) or index.php (if there's no single.php). So, yes, that's where you'll need to make a change.

    In the page describing the template tag in_category there's an example of customizing the single.php based on the category ID.

    Or you might look at Customizing your sidebar page from the Codex, where there's a reference to a "related articles" plugin.

    Best wishes.

  5. moshu
    Member
    Posted 7 years ago #

    First of all it should be category-X.php and NOT category_X.php (dash, not underscore!)

    As converting2wp pointed out Category Templates are used by WP to display the so-called category archives.

    And yes, you need a "post template" in order to have different display for single posts in a certain category.
    However, WP doesn't have that feature out of the box, so you need a plugin:
    http://guff.szub.net/2005/07/21/post-templates-by-category/
    (there is another plugin mentioned there, too)

  6. converting2wp
    Member
    Posted 7 years ago #

    Thanks for the correction and the pointer to the plugin!

Topic Closed

This topic has been closed to new replies.

About this Topic