How would I create a shortcode to display a custom post within a page or regular post?

There are great tutorials about shortcodes all over the web and some good examples here but just to get you started: add_shortcode(‘film_q’, ‘film_shortcode_query’); function film_shortcode_query($atts, $content){ extract(shortcode_atts(array( // a few default values ‘posts_per_page’ => ‘1’, ‘post_type’ => ‘film’, ‘caller_get_posts’ => 1) , $atts)); global $post; $posts = new WP_Query($atts); $output=””; if ($posts->have_posts()) while ($posts->have_posts()): $posts->the_post(); … Read more

How can i remove the paragraph from shortcodes content?

The shortcodes, since they are inserted in the editor, comply to editor rules. Hitting the return in editor will generate a paragraph tag, just like any other text. It’s one of the TinyMCE features. To read more about TinyMCE check out their forum and especially this thread

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