Created
March 2, 2020 19:58
-
-
Save Garconis/6801a93dfe52e345a9d794acc4607132 to your computer and use it in GitHub Desktop.
WordPress | ACF - Shortcode to differentiate between true and false value and if value exists at all
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function fs_sc_author_byline( $atts ){ | |
// begin output buffering | |
ob_start(); | |
global $post; // if outside the loop | |
$byline = get_field('show_author'); | |
if ( isset($byline) && $byline == '1') { | |
echo 'Set and true'; | |
} | |
elseif ( isset($byline) && $byline == '0') { | |
echo 'Set and false'; | |
} | |
else { | |
echo 'Must not be set'; | |
} | |
// end output buffering, grab the buffer contents, and empty the buffer | |
return ob_get_clean(); | |
} | |
add_shortcode( 'fs_author_byline', 'fs_sc_author_byline' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment