Need help customizing wordpress

Discussion in 'Programming' started by caj, Jul 22, 2009.

  1. #1
    I've been trying to figure out how to make this work for sometimes now. I hope fellow DPer can help me out. here is the code:

    It's about customizing the header for each blog categories in wordpress. Please help. TQ in advance. :D
     
    caj, Jul 22, 2009 IP
  2. agilius

    agilius Well-Known Member

    Messages:
    1,021
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    100
    #2
    what seems to be not working? I can't seem to find anything wrong with it :)
     
    agilius, Jul 27, 2009 IP
  3. hostcoin

    hostcoin Peon

    Messages:
    75
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    It should work and display header as per category without any error.
     
    hostcoin, Jul 28, 2009 IP
  4. qazu

    qazu Well-Known Member

    Messages:
    1,834
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    165
    #4
    Check your category IDs in your database. if (is_category('1') is for the category with ID 1, etc or else replace ('1') with the category name as in if (is_category('My Category')
     
    qazu, Jul 28, 2009 IP
  5. Webmaster Perks

    Webmaster Perks Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    The problem is your markup. You don't need to throw in the extra <?php?> tags.

    This should work:

    <?php
    
    /**** Conditional Header for Per Category Example Wordpress ****/
    
    // make sure we are in category listing
    if (is_category()) {
      if (is_category('1')) {
        include(TEMPLATEPATH.'/header-cat1.php');
      } elseif (is_category('2')) {
        include(TEMPLATEPATH.'/header-cat2.php');
      } else {
      // this is the deafult header
        include(TEMPLATEPATH.'/headerdefault.php');
      }
    }
    
    ?>
    Code (markup):
     
    Webmaster Perks, Jul 28, 2009 IP