How Can I Pass the Shortcode’s $atts Variable to the Plugin’s Javascript Function

You need to have some initial (maybe global) js var markers_array = [];. Then use an ajax callback function to bump your markers into that array. Register your scripts // Define $root_url = plugin_dir_path(); // Example path $ajax_nonce=”your_nonce”; $ajax_nonce_val=”your_val”; // Ajax wp_register_script( ‘json2’, false, false, false, true ); wp_enqueue_script( ‘json2’ ); wp_enqueue_script( ‘ajax-script’ ,”{$root_url}js/ajax_json.js” // … Read more

Using do_shortcode with variables?

Your syntax is broken, the quote marks do not match. Try to separate data from the shortcode template, and use sprintf(): $shortcode = sprintf( ‘[pw_map address=”%1$s %2$s %3$s %4$s” width=”%5$s” height=”200px”]’, $address, $city, $province, $postalcode, ‘100%’ ); echo do_shortcode( $shortcode ); That’s much easier to read, and it is harder to create syntax errors. 🙂

wp_editor returns the shortcode and not render the output

try doing this <?php $footer = get_option(‘footer_options’); $footer_content = array($footer[‘footer_content_1’], $footer[‘footer_content_2’]); foreach($footer_content as $content) { $content = apply_filters(‘the_content’, $content); echo'<aside class=”tab-content”> ‘.$content.’ </aside>’; } ?> I once had the same issue and applying the content filter solved it

How to add and submit input fields using a shortcode?

You can create the shortcode like this: add_shortcode( ‘add_fields’, ‘input_fields’ ); function input_fields( $atts ) { if ( isset( $_POST[‘gg’] ) ) { $post = array( ‘post_content’ => $_POST[‘content’], ‘post_title’ => $_POST[‘title’] ); $id = wp_insert_post( $post, $wp_error ); } ?> <form method = “post”> <input type=”text” name=”title”> <input type=”text” name=”content”> <input type=”submit” name=”gg”> </form> … Read more

Custom Shortcode, functions PHP WP_Query loop

You are returning inside your loop – so it returns on the first iteration, giving you one result only. You should build a string inside your loop instead, and only return when the loop is over. Something like $featured_properties=””; if( $featured_query->have_posts() ): while( $featured_query->have_posts() ) : $featured_query->the_post(); $featured_properties .= get_the_title() . ‘<br />’; endwhile; endif; … Read more

Trying to count the total number of paragraphs inside a blog article

I’m pretty sure that is_singular() is going to return false when you are inside the WP loop, since there are more than one posts being looped through. Try is_single() or just look at the post object and examine the post_type attribute. add_filter( ‘the_content’, ‘_some_func’, 15 ); function _some_func( $content ) { if( __check_paragraph_count_blog( $content ) … Read more

Placing the_content inside shortcode not working

It doesn’t appear that the variable $the_content exists. I’m guessing what you want is the function the_content(), but since that actually echoes its output, that won’t work either. You need to use the function get_the_content() which will return the output (as opposed to echoing it). Try this: echo do_shortcode(‘[wcm_restrict plans=”silver”]’ . get_the_content() . ‘[/wcm_restrict]’);