Need to turn this php into WP shortcode

Init your shortcode add_shortcode(‘shortcode_ald_crp’, ‘myshortcode_echo_ald_crp’); The function what you want: function myshortcode_echo_ald_crp() { ob_start(); if ( function_exists( ‘echo_ald_crp’ ) ) echo_ald_crp(); return ob_get_clean(); } you call you shortcode in a post like this: [shortcode_ald_crp] Or into the php code: echo do_shortcode(‘[shortcode_ald_crp]’); UPDATE Change the function add_shortcode shortcode_ald_crp for myshortcode_echo_ald_crp

How to change the page break numbering?

Put this function in you functions.php – function the_dramatist_wp_link_pages( $args=”” ) { global $page, $numpages, $multipage, $more; $defaults = array( ‘before’ => ‘<p>’ . __( ‘Pages:’ ), ‘after’ => ‘</p>’, ‘link_before’ => ”, ‘link_after’ => ”, ‘next_or_number’ => ‘number’, ‘separator’ => ‘ ‘, ‘nextpagelink’ => __( ‘Next page’ ), ‘previouspagelink’ => __( ‘Previous page’ ), … Read more

Display content from another site page using a shortcode

You can create a shortcode as below: function wpse250662_post_content_shortcode($atts) { $args = shortcode_atts( array( ‘pagename’ => ” ), $atts ); $query = new WP_Query( $args ); if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); $content = apply_filters(‘the_content’,get_the_content( )); ob_start(); ?> <div class=”content”> <?php echo $content; ?> </div> <?php endwhile; endif; wp_reset_postdata(); return … Read more

How do you pass parameters TO a shortcode?

Let’s say you have a form that sends the data in the following way: <form method=”post” name=”car-select” action=”<?php echo site_url(‘/my-page/’); ?>”> <select name=”make”> <option value=”benz”>Benz</option> <option value=”bmw”>BMW</option> <option value=”audi”>Audi</option> </select> <input type=”submit” value=”Find my dream car!”/> </form> Now you want to query some posts based on users choice right? This is where $_POST comes in … Read more

Adding json as params to shortcode

You could create a shortcode with only one attribute and that attribute could be the ID of a custom post type or the name of a site option: [example id=”123″] Multiple instances of the framework If you need to have multiple instances of that js framework with different attributes, then you could create a custom … Read more

get_page_by_title with an apostrophe in variable

Title Hello world!@#$%^*(),.;:\ will work but any title you enter containing ‘ ” < > & characters won’t work because in $content variable you have escaped HTML entities so Mal’s Post becomes Mal&#8217;s Post. To bypass it you can use sanitize_title function along with get_page_by_path. function shortcode_equipment($atts, $content = null) { $path = sanitize_title($content); $equipment … Read more

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