How execute shortcode with javascript

to execute “ShortCode” which server side-> wordpress ->php ,by JavaScript which client side you will need use AJAX! you can use some thing like: 1-in your enqueued .js file : jQuery(document).ready(function($) { $(‘.buttonClass’).on(‘click’, function() { $.ajax({ url: Param.doShortCode, type: ‘POST’, data: { action: ‘handle_ajax_shortcode’, }, success: function() { //do something on success }, error: function() … Read more

Shortcode with parameters inside parameters

The days of the week shortcodes aren’t needed. Also, the way you’re trying to use them isn’t allowed. Why not just use the title and do what you want in the books shortcode? function books($atts, $content = null) { $atts = shortcode_atts( [ “name” => ”, “day” => ”, “title” => ”, ], $atts ); … Read more

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