WordPress.org

Ready to get started?Download WordPress

Forums

Content for every post in each category (3 posts)

  1. Microdot
    Member
    Posted 3 years ago #

    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?

  2. MichaelH
    Member
    Posted 3 years ago #

    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.

  3. vtxyzzy
    Member
    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic