I dont want to show shortcode in tag

A) If you want to show the shortcode syntax you can try to write it with double brackets in the editor: <pre>[[shortcode foo=”bar”]]</pre> It will then display as <pre>[shortcode foo=”bar”]</pre> on your frontend and it will not activate the shortcode callback. B) Or if you want some extra formatting, you could define your own pretty … Read more

Shortcode output is screwed up when arrow symbol “

This issue was introduced in WP 4.2.3 with the introduction of the do_shortcodes_in_html_tags() function, which does a HTML parse of content to protect against content containing shortcodes authored by untrustworthy contributors/authors who by specially crafting shortcode attributes can create XSS exploits. If that security situation doesn’t apply to you and you only want this to … Read more

How do I require a file in a shortcode?

Shortcodes are expected to return content, not echo it out. So if your shortcode_file.php file is straight html, it’s considered being echoed. If that’s the case, you could do something like : function shortcode_name(){ ob_start(); require_once ( plugin_dir_path(__FILE__) . ‘/shortcode_file.php’); $content = ob_get_clean(); return $content; };

Changing playlist shortcode thumbnail sizes?

Demo Plugin – Fixed Size Here’s one suggestion as a demo plugin (PHP 5.4+): <?php /* Plugin Name: Custom Playlist Thumb Size */ namespace WPSE238646\PlaylistThumbSize; add_shortcode( ‘playlist’, function( $atts = [], $content=”” ) { add_filter( ‘wp_get_attachment_image_src’, __NAMESPACE__ . ‘\\src’ , 10, 3 ); $out = wp_playlist_shortcode( $atts, $content ); remove_filter( ‘wp_get_attachment_image_src’, __NAMESPACE__ . ‘\\src’ ); … Read more

How to put an “include” inside a “do_shortcode”?

You won’t be able to concatenate an include as it doesn’t return a string. What you could do is store that include content in a variable, and then concatenate. ob_start(); include ‘incMac.php’; $include_content = ob_get_clean(); echo do_shortcode( ‘[student]’ . $include_content . ‘[/student]’ ); ob_start tells php to store the output from the script in an … Read more

How to: How do I make my own shortcodes without plugins?

You’ll probably need to modify this a bit to ensure things get placed where you want them but here’s something I wrote that counts views on posts and displays the view counts for administrators: //ADD TRACKER FUNCTION TO ALL SINGLE VIEWS function custom_hook_tracker( $post_id ) { if( !is_single() ) return; if( empty( $post_id ) ) … Read more

Shortcode But Without The Equals Sign?

Try this: function font_fam($atts, $content = null) { extract(shortcode_atts(array( ‘f’ => isset($atts[0]) ? $atts[0] : ” , ), $atts)); return ‘<span style=”font-family:’ . $f . ‘”>’ . $content . ‘</span>’; } add_shortcode (‘f’,’font_fam’);

Audio tags around Mp3 URL in content

Filter the_content ond/or the_excerpt and replace audio URLs that are not an attribute value already. Example: add_filter( ‘the_content’, ‘wpse_82336_audio_url_to_shortcode’, 1 ); add_filter( ‘the_excerpt’, ‘wpse_82336_audio_url_to_shortcode’, 1 ); function wpse_82336_audio_url_to_shortcode( $content ) { # See http://en.wikipedia.org/wiki/Audio_file_format # Adjust the list to your needs $suffixes = array ( ‘3gp’, ‘aa3’, ‘aac’, ‘aiff’, ‘ape’, ‘at3’, ‘au’, ‘flac’, ‘m4a’, ‘m4b’, … Read more