{"id":231,"date":"2012-06-05T07:49:53","date_gmt":"2012-06-05T07:49:53","guid":{"rendered":"http:\/\/pixert.com\/blog\/?p=231"},"modified":"2014-06-09T05:15:24","modified_gmt":"2014-06-09T05:15:24","slug":"wordpress-shortcode-in-custom-fields","status":"publish","type":"post","link":"https:\/\/pixert.com\/blog\/wordpress-shortcode-in-custom-fields\/","title":{"rendered":"WordPress: Shortcode in Custom Field"},"content":{"rendered":"<p><a href=\"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2011\/03\/wordpresslogo.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"25\" data-permalink=\"https:\/\/pixert.com\/blog\/how-to-upgrade-wordpress\/wordpresslogo\/\" data-orig-file=\"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2011\/03\/wordpresslogo.png?fit=498%2C113&amp;ssl=1\" data-orig-size=\"498,113\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"WordPress &#8211; the logo\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2011\/03\/wordpresslogo.png?fit=300%2C68&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2011\/03\/wordpresslogo.png?fit=498%2C113&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2011\/03\/wordpresslogo-300x68.png?resize=300%2C68\" alt=\"\" title=\"WordPress - the logo\" width=\"300\" height=\"68\" class=\"aligncenter size-medium wp-image-25\" srcset=\"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2011\/03\/wordpresslogo.png?resize=300%2C68&amp;ssl=1 300w, https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2011\/03\/wordpresslogo.png?w=498&amp;ssl=1 498w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nNormally 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\u2019ll end up displaying the entire text, including the tags.<\/p>\n<p>Add the following in your template file, it can be single.php or page.php or else <\/p>\n<pre class=\"brush: php; title: Code Block; notranslate\" title=\"Code Block\">\r\necho apply_filters('the_content', get_post_meta($post-&gt;ID,'your_custom_field',true)); \r\n<\/pre>\n<p>or<\/p>\n<pre class=\"brush: php; title: Code Block; notranslate\" title=\"Code Block\">\r\n$shortcode=get_post_meta($post-&gt;ID,'your_custom_field',true);\r\necho do_shortcode($shortcode); \r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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\u2019ll end up displaying the entire text, including the tags. Add the following in your template file, it [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[54,5],"tags":[55,135,106,6,7],"class_list":["post-231","post","type-post","status-publish","format-standard","hentry","category-code-snippet","category-wordpress","tag-code-snippet-2","tag-custom-fields","tag-shortcodes","tag-wordpress-2","tag-wp"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1pvi1-3J","jetpack-related-posts":[{"id":208,"url":"https:\/\/pixert.com\/blog\/how-to-add-a-wordpress-shortcode-outside-post-editor-php-template\/","url_meta":{"origin":231,"position":0},"title":"How to add a WordPress shortcode outside of the post editor or  PHP templates","author":"Pixel Insert \/ Pixert","date":"March 13, 2012","format":false,"excerpt":"Shortcodes were introduced back in WordPress 2.5. Shortcodes are for creating macros to be use in a posts. For instance, the following shortcode (in the post\/page content) would add a photo gallery into the page: [ \u00a0gallery \u00a0] If you want to use that shortcode outside of the WordPress post\u2026","rel":"","context":"In &quot;Code Snippet&quot;","block_context":{"text":"Code Snippet","link":"https:\/\/pixert.com\/blog\/category\/code-snippet\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2011\/03\/wordpresslogo-300x68.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":268,"url":"https:\/\/pixert.com\/blog\/wordpress-limit-post\/","url_meta":{"origin":231,"position":1},"title":"WordPress Limit Post","author":"Pixel Insert \/ Pixert","date":"November 30, 2012","format":false,"excerpt":"This function controls the maximum\u00a0amount of characters displayed for an entry on the main page. If the set limit is surpassed, the text on the entry will be chopped\u00a0to that amount of characters, otherwise the content will be showed unchanged. Add following code to functions.php in your theme folder [php]\u2026","rel":"","context":"In &quot;Code Snippet&quot;","block_context":{"text":"Code Snippet","link":"https:\/\/pixert.com\/blog\/category\/code-snippet\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2011\/03\/wordpresslogo-300x68.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":279,"url":"https:\/\/pixert.com\/blog\/keep-html-tags-wordpress-limit-posts\/","url_meta":{"origin":231,"position":2},"title":"Keep HTML Tags in WordPress Limit Posts &#8211; the_content_limit","author":"Pixel Insert \/ Pixert","date":"January 8, 2013","format":false,"excerpt":"This function, the_content_limit \u00a0controls the maximum\u00a0amount of characters displayed for an entry on the main page on WordPress homepage posts, e.g Featured Posts, Recent Posts However , the_content_limit stripped HTML tags just like the_excerpt. What if we want to keep HTML tags We make modification to the function, the_content_limit which\u2026","rel":"","context":"In &quot;Code Snippet&quot;","block_context":{"text":"Code Snippet","link":"https:\/\/pixert.com\/blog\/category\/code-snippet\/"},"img":{"alt_text":"WordPress - the logo","src":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2011\/03\/wordpresslogo-300x68.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":227,"url":"https:\/\/pixert.com\/blog\/mp4-video-cannot-play-on-ipad-ipod-iphone-using-jw-player-shortocode\/","url_meta":{"origin":231,"position":3},"title":"MP4 video cannot play on iPad\/iPod\/iPhone using JW Player shortcode","author":"Pixel Insert \/ Pixert","date":"May 14, 2012","format":false,"excerpt":"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\u2026","rel":"","context":"In &quot;iOS&quot;","block_context":{"text":"iOS","link":"https:\/\/pixert.com\/blog\/category\/ios\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":326,"url":"https:\/\/pixert.com\/blog\/wordpress-how-to-hide-custom-fields-meta-key-from-custom-fields-panel\/","url_meta":{"origin":231,"position":4},"title":"WordPress: How to Hide Custom Field Meta Key from Custom Fields panel","author":"Pixel Insert \/ Pixert","date":"October 31, 2013","format":false,"excerpt":"I learned this trick when someone asked about How to Hide Custom Fields Meta Key from Custom Fields panel. This trick useful when you want to hide certain Custom Fields Meta Key and Value from client or authors Add following code to functions.php [php] add_filter('is_protected_meta', 'my_is_protected_meta_filter1', 10, 2); function my_is_protected_meta_filter1($protected,\u2026","rel":"","context":"In &quot;Code Snippet&quot;","block_context":{"text":"Code Snippet","link":"https:\/\/pixert.com\/blog\/category\/code-snippet\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2013\/10\/customfields.png?fit=810%2C300&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2013\/10\/customfields.png?fit=810%2C300&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2013\/10\/customfields.png?fit=810%2C300&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2013\/10\/customfields.png?fit=810%2C300&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":218,"url":"https:\/\/pixert.com\/blog\/how-to-fix-custom-field-for-thumbnails-wpzoom-featured-category-widget\/","url_meta":{"origin":231,"position":5},"title":"How to fix Custom Field for thumbnails in WPZoom Featured Category widget","author":"Pixel Insert \/ Pixert","date":"April 6, 2012","format":false,"excerpt":"WPZoom Featured Widget is a widget built inside WPZOOM themes to show Featured Category posts The widget display thumbnail images, post titles and post meta datas from selected Featured Category There's a bug in wpzoom-widgets.php where as all widgets code are. The widget cannot display thumbnail images from custom field\u2026","rel":"","context":"In &quot;Code Snippet&quot;","block_context":{"text":"Code Snippet","link":"https:\/\/pixert.com\/blog\/category\/code-snippet\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/pixert.com\/blog\/wp-content\/uploads\/2012\/04\/featuredcat-208x300.jpg?resize=350%2C200","width":350,"height":200},"classes":[]}],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/posts\/231","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/comments?post=231"}],"version-history":[{"count":0,"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/posts\/231\/revisions"}],"wp:attachment":[{"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/media?parent=231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/categories?post=231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pixert.com\/blog\/wp-json\/wp\/v2\/tags?post=231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}