Skip to content

Instantly share code, notes, and snippets.

@braddalton
Created September 7, 2018 07:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save braddalton/86b0b235aef30b2d1c787b3f740c6fd1 to your computer and use it in GitHub Desktop.
Save braddalton/86b0b235aef30b2d1c787b3f740c6fd1 to your computer and use it in GitHub Desktop.
Using if elseif else conditional statements in Genesis https://wpsites.net/php-code/if-else/
add_action( 'genesis_before_content_sidebar_wrap', 'if_elseif_else_code_test' );
function if_elseif_else_code_test() {
if ( is_front_page() ) {
echo '<p style="color:blue;">This prints on your front page</p>';
} elseif ( is_singular('post') ) {
echo '<p style="color:green;">This text prints on all single posts excluding your front page</p>';
} else {
echo '<p style="color:red;">Print this on all pages if all other conditions return false</p>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment