WordPress.org

Forums

Calling a different footer for each page (8 posts)

  1. audrys
    Member
    Posted 7 years ago #

    hi is it possible to call a different footer for each post. lets say post 42 needs footer1.php thanks

  2. NeXXor
    Member
    Posted 7 years ago #

    you can include footer42.php for post 42 by calling

    <?php include("footer".$post->ID.".php") ?>

    inside the loop.

  3. audrys
    Member
    Posted 7 years ago #

    hmm.. I added the above code into my page.php right below 'get footer' and page didn't load. can you please please give me a working example

    <?php include("footer1".$post->42.".php") ?>

    and how about catagories ??

    want you to know that I have several different footers that I'd like to place with a particular post or cat

  4. whooami
    Member
    Posted 7 years ago #

    you didnt use what he provided..

    what he provided uses the same numbered footer for the same number post.

    <?php include("footer".$post->ID.".php") ?>

    does not equal what you did.

    Using the example provided, the post wth id 42 will be looking for footer42.php

  5. audrys
    Member
    Posted 7 years ago #

    ok will try that but one last silly question: where do I add this code??

    underneath the 'get footer' on page.php

  6. audrys
    Member
    Posted 7 years ago #

    and also how to apply when I am calling for category like ?cat=42

  7. NeXXor
    Member
    Posted 7 years ago #

    In fact, you cannot use get_footer anymore. Just use the code I provided instead.

    To get another footer for your category, you must use the causal tags someho like this:

    if(is_single()) {
       include("footer".$post->ID.".php");
    }else{
       get_footer();
    }

    This will include the post-specific footer (footerX.php) for every post, and a common footer (footer.php) for every other page/category/search...

  8. moshu
    Member
    Posted 7 years ago #

    And a note: you do NOT add it to the page.php - that file is to display Pages not posts.
    Reading about the Template_Hierarchy is always useful...

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags