Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.