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

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -