WordPress: Shortcode in Custom Field


Normally wordpress does not run shortcode that you put into a custom field. By default, Custom Fields display whatever value you enter, as plain-text, so if you try entering a shortcode, (in the format [shortcode] VALUE [/shortcode]) you’ll end up displaying the entire text, including the tags.

Add the following in your template file, it can be single.php or page.php or else

echo apply_filters('the_content', get_post_meta($post->ID,'your_custom_field',true)); 

or

$shortcode=get_post_meta($post->ID,'your_custom_field',true);
echo do_shortcode($shortcode); 

WordPress: Disable All Shortcodes from the_content


The following code snippet will remove ALL shortcodes from the_content
Add the following code snippet to the functions.php of your theme

function remove_shortcode_from_index($content) {            
$content = strip_shortcodes($content);          
return $content; 
} 
add_filter('the_content', 'remove_shortcode_from_index');  

You can disable shortcodes from particular page, e.g Home Page

function remove_shortcode_from_index($content) {     
if ( is_home() ) {         
$content = strip_shortcodes($content);     
}     
return $content; 
} 
add_filter('the_content', 'remove_shortcode_from_index');  

MP4 video cannot play on iPad/iPod/iPhone using JW Player shortcode

It seems that this is a bug on JW Player for WordPress plugin
We added JW Player or WordPress plugin shortcode with a mp4 video in it, the video plays on Macbooks and PCs, but it shows blank on iPad or iPod or iPhone.
Although HTML5 as default mode, it doesn’t work.

How to fix that?
1. Browse Media subfolder, find it inside wp-content/plugins/jw-player-plugin-for-wordpress
1. Open JWShortcode.php with PHP/Text Editor
2. Find function generate_embed_code($atts) in line no 233 – 265
3. Replace the function code with following

function generate_embed_code($atts) {
  $version = version_compare(get_option(LONGTAIL_KEY . "version"), "5.3", ">=");
  $embedder = file_exists(LongTailFramework::getEmbedderPath());
  if (preg_match("/iP(od|hone|ad)/i", $_SERVER["HTTP_USER_AGENT"])) {
    $loaded_config = LongTailFramework::getConfigValues();
    $width = isset($atts["width"]) ? $atts["width"] : $loaded_config["width"];
    $height = isset($atts["height"]) ? $atts["height"] : $loaded_config["height"];
    $output = '<video src="' . $atts["file"] . '" width="' . $width . '" height="' . $height . '" controls="controls"></video>';
    return $output;
  } else {
  if (!$embedder && !$version) {
    $youtube_pattern = "/youtube.com\/watch\?v=([0-9a-zA-Z_-]*)/i";
    $loaded_config = LongTailFramework::getConfigValues();
    $width = isset($atts["width"]) ? $atts["width"] : $loaded_config["width"];
    $height = isset($atts["height"]) ? $atts["height"] : $loaded_config["height"];
    $output = "";
    if (preg_match($youtube_pattern, $atts["file"], $match)) {
      $output = '<object width="' . $width . '" height="' . $height . '"><param name="movie" value="http://www.youtube.com/v/' . $match[1] . '&amp;hl=en_US&amp;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' . $match[1] . '&amp;hl=en_US&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="' . $width . '" height="' . $height . '"></embed></object>';
    } 
    return $output;
  } else {
    if (get_option(LONGTAIL_KEY . "player_location_enable")) {
      $swf = LongTailFramework::generateSWFObject($atts, $embedder, get_option(LONGTAIL_KEY . "player_location"));
    } else {
      $swf = LongTailFramework::generateSWFObject($atts, $embedder);
    }
    if (!get_option(LONGTAIL_KEY . "use_head_js")) {
      insert_embedder($embedder);
    }
    return $swf->generateEmbedScript();
  }
  }
}