Last Updated: February 25, 2016
·
30.56K
· rajeshkhatri13

If , else condition in wordpress

<h2>If , else if , else condition</h2>


<?php
if (is_page('12')) {
    // below content only show when page id is 12
    echo 'This is page id 12';

} elseif ( is_page( '14' ))  {  
// if page id is 14 then it will show below line only
echo 'Email me for to discuss your project';

}

// if page id is not 12 & 14 then below line will be print
else { 
  echo 'Get Your Water Bore Quote Here!';
  } 


?>
</code></pre>

<h2>If home condition</h2>

<?php
if ( isfrontpage() ) {
    // This is a homepage
} else {
    // This is not a homepage
}
?>
</code></pre>