Display a text message if the shortcode is not found?

do_shortcode() returns content with shortcodes filtered out. We can check the return value and display appropriate message accordingly.

$output = do_shortcode( '[picu_list_collections email="' . $current_user->user_email . '"]' );

// the shortcode returns an empty <ul> tag, if there is no gallery 
// https://plugins.trac.wordpress.org/browser/picu/trunk/frontend/includes/picu-template-functions.php#L464

if($output == '<ul class="picu-collection-list"></ul>') echo "Nothing here";
else echo $output;

I hope this may help!

References:

  1. do_shortcode()
  2. [picu_list_collections]

Leave a Comment