Forums

[resolved] Custom sidebar (1 post)

  1. peiqinglong
    Member
    Posted 6 years ago #

    I need some php help...I'm using this: http://codex.wordpress.org/Conditional_Tags#Variable_Sidebar_Content

    Here is my custom code:
    <div class="sidebar">
    <?php
    // let's generate info appropriate to the page being displayed
    if (is_home()) {
    // we're on the home page, so let's show a list of all top-level categories
    echo "<h2>Categories</h2>

      ";
      wp_list_cats('optionall=0&sort_column=name&list=1&children=0');
      echo "
    ";
    } elseif (is_category()) {
    // we're looking at a single category view, so let's show _all_ the categories
    echo "<h2>Categories</h2>
      ";
      wp_list_cats('optionall=0&sort_column=name&list=1&children=0');
      echo "
    ";
    } elseif (is_single()) {
    // we're looking at a single page, so let's not show anything in the sidebar
    } elseif (is_page()) {
    // we're looking at a static page. Which one?
    if (is_page('About')) {
    // our about page.
    echo "This is my about page!";
    } elseif (is_page('resume')) {
    echo "This is my resume page.";
    } elseif (is_page('andrea-and-rich')) {
    echo "<h2>Pictures</h2>This is a test.";
    } else {
    // catch-all for other pages
    echo "Vote for Pedro!";
    }
    } else {
    // catch-all for everything else (archives, searches, 404s, etc)
    echo "";
    } // That's all, folks!
    ?>
    </div>

    My question is how do I add extra sidebar to the main page? Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.