Posted by Table for Five Tue 6th Mar 2007 22:57 - Syntax is None/text - 32 views
Download | New Post | Modify | Hide line numbers
Description:
This is from the Wordpress Codex for Conditional tags; how to create a Variable
Sidebar.

  1. // let's generate info appropriate to the page being displayed
  2. if (is_home()) {
  3.         // we're on the home page, so let's show a list of all top-level categories
  4.         echo "
      ";
  5.         wp_list_cats('optionall=0&sort_column=name&list=1&children=0');
  6.         echo "";
  7. } elseif (is_category()) {
  8.         // we're looking at a single category view, so let's show _all_ the categories
  9.          echo "
      ";
  10.         wp_list_cats('optionall=1&sort_column=name&list=1&children=1&hierarchical=1');
  11.         echo "";
  12. } elseif (is_single()) {
  13.         // we're looking at a single page, so let's not show anything in the sidebar
  14. } elseif (is_page()) {
  15.         // we're looking at a static page.  Which one?
  16.         if (is_page('About')) {
  17.              // our about page.
  18.              echo "

    This is my about page!

    ";
  19.         } elseif (is_page('Colophon')) {
  20.              echo "

    This is my colophon page, running on WordPress " . bloginfo('version') . "

    ";
  21.         } else {
  22.               // catch-all for other pages
  23.               echo "

    Vote for Pedro!

    ";
  24.         }
  25. } else {
  26.         // catch-all for everything else (archives, searches, 404s, etc)
  27.         echo "

    Pedro offers you his protection.

    ";
  28. } // That's all, folks!
  29. ?>
  •  

  • PermaLink to this entry https://pastebin.co.uk/11501
    Posted by Table for Five Tue 6th Mar 2007 22:57 - Syntax is None/text - 32 views
    Download | New Post | Modify | Hide line numbers

     

    Comments: 0