How to minimize this PHP IF Statement?

jack

New member
This is what I'm using now:

<?php if(is_home()){ ?>

something

<?php } ?>

<?php if(is_single()){ ?>

something 2

<?php } ?>

<?php if(is_category()){ ?>

something 3

<?php } ?>

<?php if(is_tag()){ ?>

something 4

<?php } ?>

The above works but I have a feeling that it can be minimized. I don't know PHP so if someone could please minimize this code I would really appreciate it. Thank you.
 
What's the point in minimizing that?

May be you can try 'if..else if..else' construct in case your logic needs the if's to be mutually exclusive.

Or you might have meant this :

<?php
if(is_home()) {
echo "-- something 1 html code --";
}
if(is_single()) {
echo "-- something 2 html code--";
}
if(is_category()) {
echo "-- something 3 html code--";
}
if(is_tag()) {
echo "-- something 4 html code--";
}
?>

Hope that Helps!
 
Back
Top