• I want a smal text and HTML code to change in the footer.php depending of which category the article you are reading at the moment belongs to.

    Is this possible? Does anyone know how?

Viewing 2 replies - 1 through 2 (of 2 total)
  • <?php
    $post = $wp_query->post;
    if ( in_category(‘4’) ) {include(TEMPLATEPATH . ‘/footer-4.php’);}

    else

    if ( in_category(‘3’) ) {include(TEMPLATEPATH . ‘/footer-3.php’);}

    else

    if ( in_category(‘2’) ) {include(TEMPLATEPATH . ‘/footer-2.php’);}

    else

    {include(TEMPLATEPATH . ‘/footer-1.php’);}
    ?>

    Backup your files first, then save the above code as ‘footer.php’. Then create as many unique footers as you want (footer-1.php, onwards). In this example, if the category is category 2, you’ll get footer-2.php, and so on.

    Hope this helps…

    Thread Starter johanlundin88

    (@johanlundin88)

    Thanks! This is a other possible way to do it:

    <?php if ( in_category('1') ){ ?>
    1
    <?php } elseif ( in_category('2') ) { ?>
    2
    <?php } else { ?>
    Alla
    <?php } ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Change text int footer depending on category’ is closed to new replies.