WordPress.org

Support

Support » How-To and Troubleshooting » Multiple Conditions

Multiple Conditions

  • Hi,
    Because of my client’s webhost I have to use wordpress as a CMS. I am banging my head over how to do this, basically I have navigation that needs to change based on the post’s category and also section. So I don’t know how to do this, because I think I have something wrong in the code below. ALSO I need to insert links in there, so like in the category “services” I need it to show a list of links. How would I go about doing that. The category ‘services’ and the page “services” would display the exact same navigation but I’m unsure how I would combine them.

    <?php
    if (is_home()) {
            echo " ";
    } elseif (is_category()) {
            if (is_category('services')) {
                 echo "<p>Our Services</p>";
            } elseif (is_category('business')) {
                 echo "Business";
            } elseif (is_category('products')) {
                 echo "Products";
            } else {
                  echo "";
    } elseif (is_page()) {
            if (is_page('Services')) {
                 echo "Services Navigation";
            } elseif (is_page('Business')) {
                 echo "Business Navigation";
            } elseif (is_page('Products')) {
                 echo "Products Navigation";
            } else {
                  // catch-all for other pages
                  echo "<p>Vote for Pedro!</p>";
            }
    } else {
            echo "";
    }
    ?>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Multiple Conditions’ is closed to new replies.