Skip to content

Instantly share code, notes, and snippets.

@technoknol
Last active January 4, 2016 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save technoknol/8683882 to your computer and use it in GitHub Desktop.
Save technoknol/8683882 to your computer and use it in GitHub Desktop.
Shortcode Tweaks
<?php
// Shortcode Working in PHP file
// Method 1 :
echo do_shortcode ('[easingsliderlite]') ;
// Method 2 : // easingsliderlite() is a function used by shortcode [easingsliderlite]
if ( function_exists( "easingsliderlite" ) ) { easingsliderlite(); }
// ADD SHORTCODE WORKING IN TEXT_WIDGET
// Use shortcodes in text widgets.
add_filter('widget_text', 'do_shortcode');
add_filter('the_content', 'do_shortcode', 11); // From shortcodes.php
// Use shortcode in a PHP file (outside the post editor).
echo do_shortcode('[gallery]');
// In case there is opening and closing shortcode.
echo do_shortcode('[iscorrect]'.$text_to_be_wrapped_in_shortcode.'[/iscorrect]');
// Use shortcodes in form like Landing Page Template
echo do_shortcode('[contact-form-7 id="91" title="quote"]');
// Make shortcode working anywhere
// like in woo_commerce custom tab
// varibale name that will be printed in new tab.
// add this code in your custom tab function.
// method 1
$newtab_content = get_post_meta(get_the_ID(), 'your custom field name', true) ;
$newtab_content = do_shortcode($newtab_content);
// method 2
echo apply_filters('the_content', get_post_meta($post->ID, 'your custom field name', true));
// method 3
echo do_shortcode(get_post_meta(get_the_ID(), 'your custom field name', true));
---------------------------------------------------------------------------------------------------------------------
// Filter Reference
http://codex.wordpress.org/Plugin_API/Filter_Reference
// Do shortcode reference
http://codex.wordpress.org/Function_Reference/do_shortcode
// Add Shortcode Reference
http://codex.wordpress.org/Function_Reference/add_shortcode
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment