WordPress.org

Support

Support » How-To and Troubleshooting » Content for every post in each category

Content for every post in each category

  • Hey guys I’m wondering if this is possible..

    I’d like to display custom content in each post, depending on which category it’s in.

    So for example, if the post is in the ‘apples’ category, every post in that category will display extra content about apples.

    Again if the post is in the ‘oranges’ category, it will display custom content about organges in all posts from that category.

    Does a plugin exist to do this or is there a way to make it happen?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The question would be, where are you storing the ‘extra content about apples’ text? Category Templates are one solution and if you put that extra content in your category’s description you can easily display that information via your Category Template.

    I don’t know of a plugin, but you can use the in_category() function in your templates to test for the categories and insert the extra content.

    I suggest either using category templates or making a function to prepare the text and calling it just after calling the_content() in your templates.

    Where to store the extra text could be a bit of a problem. If there is not much of it, and it doesn’t change, you could put it directly in the template or furction. If there are many categories, or if the text is lengthy, or if it changes very much, you need to keep it in posts or pages so it can be edited.

    Keeping it in posts or pages raises a new problem, though. You don’t want those posts showing up in the blog with the others, so you need a way to keep them separate.

    This could get complicated. Are you up to coding it?

    EDIT: Michael beat me to it.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Content for every post in each category’ is closed to new replies.