php - Conditional statement for WordPress Shortcodes -
i have 2 shortcodes setup: [easy_options id="companyname"]
, [easy_options id="companylogo"]
i'm wanting wordpress check if [easy_options id="companylogo"]
holds data (an image upload), if not display [easy_options id="companyname"]
(plain text)...
is possible? if please point me in right direction?
you can using switch case follow:
function easy_options_shortcodes( $atts ) { extract( shortcode_atts( array( 'id' => 'companyname' //cosidering defaultvalue ), $atts ) ); switch( $id ){ case 'companyname': $output = '<div class="classcompanyname"></div>'; break; case 'companylogo': $output = '<div class="companylogo"></div>'; break; default: $output = '<div class="defaultshortcodecontent"></div>'; break; } return $output; } add_shortcode( 'easy_options', 'easy_options_shortcodes' );
Comments
Post a Comment