Wordpress - Archives: Category or Month?

Discussion in 'WordPress' started by Sam Designs, Nov 18, 2007.

  1. #1
    In archive.php, is there some sort of code to determin if it's an archive with a category or an archive with a certain month? As i'd like to have it say November 2007 or Uncategorized etc.

    Also is there a code for it to post the current archive's name, for example:

    I click on Uncategorized, at the top it says Uncategorized. If i clicked Products, at the top it would say Products. Don't worry about CSS, i just need the php code etc to do this.

    Thanks in advance.
     
    Sam Designs, Nov 18, 2007 IP
  2. Sam Designs

    Sam Designs Active Member

    Messages:
    474
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #2
    News: <?php single_cat_title(''); ?>

    That works for getting the category, but if you're looking at a Month - it doesn't work. Any fix?
     
    Sam Designs, Nov 18, 2007 IP
  3. mizaks

    mizaks Well-Known Member

    Messages:
    2,066
    Likes Received:
    126
    Best Answers:
    0
    Trophy Points:
    135
    #3
    For monthly archives use:

    <?php wp_get_archives('type=monthly'); ?>
    Code (markup):
    For category archives use:

    <?php wp_list_categories('title_li='); ?>
    Code (markup):
     
    mizaks, Nov 18, 2007 IP
  4. Sam Designs

    Sam Designs Active Member

    Messages:
    474
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #4
    That isn't really what I wanted, that just lists all the available categories. I wanted it to tell me which archive i'm looking at, whether it be a month or a category archive.

    I have got the category part sorted, <?php single_cat_title(''); ?>; but i haven't got a piece of code for the months yet.
     
    Sam Designs, Nov 19, 2007 IP