WordPress.org

Ready to get started?Download WordPress

Forums

Change text int footer depending on category (3 posts)

  1. johanlundin88
    Member
    Posted 6 years ago #

    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?

  2. jhorbury
    Member
    Posted 6 years ago #

    <?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...

  3. johanlundin88
    Member
    Posted 6 years ago #

    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 } ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags