shortcode javascript not working on custom template file inside theme folder

You haven’t included get_header() or get_footer() in your template. They will load header.php and footer.php which should include wp_head() and wp_footer(). Those last two functions are important because that’s where scripts are loaded. If your shortcode depends on a script being loaded in the header or the footer, then you need wp_head() or wp_footer(), thats … Read more

How to modify shortcode attributes with data from current post

For anyone who might stumble upon this, I’ve found a solution: In my particular case, I’m using a single-[taxonomy].php template file, and was able to add the shortcode manually via the WordPress function do_shortcode() instead of modifying a shortcode within the post content. Here’s how I wrote it: <?php echo do_shortcode( ‘[mstw_schedule_table sched=”‘.$sports_slug.'” ]’ ); … Read more

Remove wpautop from specific shortcodes only

Well, there is a script out there. The author claims that it removes the wpautop form individual specific shorcodes. You’ll find it here. Add this to your functions.php or your plugin like below- // Here I assumed that you kept the name of the PHP script file same include “shortcode-wpautop-control.php”; And then call the function … Read more

Shortcode produces blank page

I agree that there is a coding error – a blank WP page is almost always caused by a fatal PHP error. You should look at the error.log file in your site’s root folder. That will tell you what/where about the error. If you edit your question to include the error messages found in error.log, … Read more

Demystifying and understanding shortcode nomenclature

It’s just [link to= “https://wordpress.stackexchange.com/”]. This is a textbook example of why extract() is bad. You can’t easily tell where variables are coming from. extract() creates variables out of an array with the keys becoming the variable name. So this part: extract(shortcode_atts(array( “to” => ‘http://net.tutsplus.com’ ), $atts)); Is creating an array with a to key, … Read more

Add custom setting that uses radio button to WP Gallery

I had the same problem and got it finally to work. Based on the thread you have followed, you now have to extend the “update” function of the WP core /wp-includes/js/media-views.js. Go to the “jQuery(document).ready(function()…” part of the ‘print_media_templates’ action and try this: <script> jQuery(document).ready(function() { wp.media.view.Settings.Gallery = wp.media.view.Settings.Gallery.extend({ // add your custom options template … Read more

Shortcode insertion in tab

Sounds like you need to wrap your shortcode contents in ob_start()and return ob_get_clean() require_once(dirname(__FILE__).’/post-type.php’); //file that registers CPT function wporg_shortcodes_init(){ function wporg_shortcode($atts = []) { extract( shortcode_atts( array( ‘term’ => ‘columns’ ), $atts ) ); $custom_taxonomy = $atts[‘term’]; ob_start(); // <- works like magic // add query of custom post type board_members $recentPosts = new … Read more

Two Shortcodes in one page not working

I simply replaced require_once dirname( __FILE__ ) . ‘/swt_mm_single_box.php’; with define(‘__ROOT__’, dirname(__FILE__)); include __ROOT__.’/swt_mm_single_box.php’; and now its worked for me. check Here