WordPress.org

Ready to get started?Download WordPress

Forums

Call sidebar once only! (3 posts)

  1. dawg
    Member
    Posted 9 years ago #

    I am having troubles figuring out how to call the sidebar on only the index page. I have put the call on the index/header/footer files and it works the same on all of them.

    //<?php
    include_once("sidebar.php");

    ?>//

    This is how I call it, I used require once and it worked the same as well as with// <?php get_sidebar (); ?>//

  2. asianmack
    Member
    Posted 9 years ago #

    You can also do something like this:

    <?php
    // If Category, Page, or Search are not equal to zero, display nothing
    if ($cat != "" || $p != "" || $s !="") {
    ?>
    <?php
    } else {
    ?>
    // Else, if it's on the index, show display this Get Sidebar function
    <?php get_sidebar (); ?>
    <?php
    }
    ?>

    That might work. Good luck.

  3. dawg
    Member
    Posted 9 years ago #

    Very good piece of coding, I would not have come up with that but it works. Thanks asianmack I'm impressed.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.