WordPress.org

Support

Support » How-To and Troubleshooting » Call sidebar once only!

Call sidebar once only!

  • 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 (); ?>//

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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.

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Call sidebar once only!’ is closed to new replies.