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 … Read more

Custom Shortcode AJAX 400 Bad Request

The problem is that you’re attempting to use the arguments for the jQuery AJAX API with the native Fetch API. Specifically, the problem is that the JS Fetch API doesn’t support a data argument. For an admin-ajax.php request to work in WordPress the $_REQUEST[‘action’] property needs to be populated, and to do this with the … Read more

How To Ignore a Filter On Applying Filter the Content In a Function

You can temporarily detach the function from the hook. // THIS IS MY PROBLEM LINE, i USE Apply Filters for post content…. $priority = has_filter(‘the_content’, [‘TableOfContents’, ‘writeTOC’] ); if ( $priority !== false ) remove_filter(‘the_content’, [‘TableOfContents’, ‘writeTOC’], $priority ); $meta = apply_filters(‘the_content’, $post->post_content); if ( $priority !== false ) add_filter(‘the_content’, [‘TableOfContents’, ‘writeTOC’], $priority ); $meta … Read more

Can shortcodes contain conditional statements? Even without them my shortcode renders blank page

your conditional breaks the concatenation of the strings (which is not in your code, anyway) try to re-write this section: function info($atts, $content = null) { extract(shortcode_atts(array( “name” => ”, “image” => ”, “address” => ”, “phone” => ”, “email” => ”, “website” => ”, “description” => ”, “amenities” => ” ), $atts)); $output=”<span class=”sort”>”; … Read more

How to use get_media_embedded_in_content function

The get_media_embedded_in_content() function is a handy helper function, though it doesn’t seem to be used in the core (ver. 4.2.2). Regular expression: To understand the get_media_embedded_in_content() function, we must understand the following regular expression: #<(?P<tag>video|audio|object|embed|iframe)[^<]*?(?:>[\s\S]*?<\/(?P=tag)>|\s*\/>)# There are many online regular-expression tools to help us with that. Like this one: Debuggex demo We note that it’s … Read more