Created
January 5, 2023 17:33
-
-
Save vaakash/cd5cf6d727d6ebb37ac961b70f160183 to your computer and use it in GitHub Desktop.
Create a shortcode which will conditional print shortcoder shortcode
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 | |
/* Create a shortcode which will conditional print shortcoder shortcode */ | |
function sc_condition_function($args){ | |
$category = get_the_category(); | |
$firstCategory = $category[0]->cat_name; | |
if( $firstCategory = 'my_category' ){ | |
echo do_shortcode( '[sc name="sc1"]' ); | |
}else{ | |
echo do_shortcode( '[sc name="sc2"] ); | |
} | |
} | |
add_shortcode('sc_condition', 'sc_condition_function'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment