Support » Plugins » Custom Content Shown By Category

  • Is there a plugin that will let me add, say, a few lines of text or an image to the archive pages, but it’s different (or not there) depending on what catergory it is.
    I’d like to use it for a game blog, so in the Nintendo DS Category it would show a piece of text explaining the latest editorial/review about the DS.

    Any help would be great.

Viewing 5 replies - 1 through 5 (of 5 total)
  • This might give you a start:
    Category_Templates#Custom_Category_Page_Text
    or check out the archive.php of the default theme.

    Thread Starter jonathanex

    (@jonathanex)

    I’ll check that out now. Thank you very much 🙂

    Thread Starter jonathanex

    (@jonathanex)

    I’m looking at the thing with
    # category-6.php
    # category.php
    # archive.php
    # index.php

    as the files it looks for – but I don’t have a category.php
    I know this makes it look for the next file, but I’d like to create a catergory-6 (or equivilant number) file and I’m not sure what to base it off without a category.php file… should I make a copy of archive.php and edit that?

    you can likely copy archive or index, depending on what you want the display to look like (it depends on the particular theme…).

    alternately, you COULD just add to your index/archive a DIV wrappering the overall content, with an id= or class= as the category id or clean name (cat-1 or cat-nintendods). Then, use CSS to custom-style things under that id/class.

    So long as you WANT the archives to all lay-out identical, but maybe flip images or something, that’s an easy approach.

    You can also use custom code to pull text from a file, or the database, based on the category name/id as well…

    Just some ideas,

    -d

    I originally did this on my blog by creating several different category-X.php pages, but that required a lot of duplicate code and so seemed inelegant to me.

    If you want a cleaner way to do it and aren’t afraid of some hacking, you could try using the fetch_category_id function I wrote. Right now I have this in my sidebar.php file:

    <?php if(is_category()) {
    echo_cat_heading(fetch_category_id());
    }
    ?>

    where echo_cat_heading is another function I wrote, via a very quick and dirty plugin, that uses the category ID number as an index into an array of category-specific text strings and prints the appropriate one, like so:

    function echo_cat_heading($cat) {
    $categoriesd = array(
    3 => "test",
    4 => "test 2",
    5 => "etc.",
    );
    $desc = '<p class="justify"><i>' . $categoriesd[$cat] . '</i></p>';
    echo $desc;

    Does that help?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom Content Shown By Category’ is closed to new replies.