Nice one, you were practically there – the key is to assign the $ecpt_imdb variable with the data returned from get_post_meta:
<?php if ( $ecpt_imdb = get_post_meta( get_the_ID(), 'ecpt_imdb', true ) ) : ?>
<h3>About the Movie</h3>
<?php echo do_shortcode( '[imdb]http://www.imdb.com/title/' . $ecpt_imdb . '/[/imdb]' ) ?>
<?php endif ?>
You’ll see I’ve also used the template tag get_the_ID(), which is the “correct” way of getting the current post ID.
Related Posts:
- Return HTML Template Page with PHP Function
- How do I use Shortcodes inside of HTML tags?
- WordPress Shortcode and Dynamic CSS
- ob_get_clean returns empty string, ob_get_flush outputs string
- How to create shortcodes that pull custom field data from general settings
- Creating a WordPress shortcode
- the_title() & the_content() are retrieving Post details inside a Page, after calling a shortcode
- Get list of shortcodes from content
- Audio tags around Mp3 URL in content
- How do I hardcode a WordPress shortcode into my theme?
- has_shortcode() – how to detect nested shortcode
- How to return multiples lines in a shortcode?
- Wrap each shortcode in array to div
- How do I turn a shortcode into PHP code?
- Put php variable in shortcode
- Placing raw HTML inside a WordPress shortcode
- How do I add text in a shortcode?
- Template part inside shortcode, unexpected reult
- Shortcode Inside Class Not Working
- Shortcode content output but not in correct place
- PHP code inside shortcodes
- Shortcode API: How to get name that matched shortcode RegEx?
- Shortcode content filter?
- How to display posts by current user in a drop down
- Get value from shortcode to do something
- Colon is Missing In My Website Url in WordPress
- Custom shortcode outputs plain text instead of HTML at top of post
- Pass php dynamic variable to shortcode
- wordpress 4.4 self hosted video (html5) doesn’t show
- Remove echo from shortcode
- Shortcode returns values in the wrong order
- Embedding PHP in shortcode $content
- Shortcode with PHP issue “Undefined index”
- Excecuting php function in shortcode
- Returning data instead of echoing/printing
- List taxonomy term slugs within shortcode (do_shortcode)
- ::before on open/close function [closed]
- Is There A Way To Make Theme Files Accept Shortcodes?
- Is it possible to define variables in a wordpress shortcode, and then call the shortcode using a specific variable?
- Create a WordPress shortcode using PHP [duplicate]
- do_action(), iFrame Gets Displayed Despite Password Protection [closed]
- Using Shortcode to Grab Archive Listing, Separate by Year
- Unable to process php via shortcode
- calling a custom field value inside functions.php
- Using ob_start and ob_get_clean with wordpress shortcode
- List all blogs, but exclude the main site
- Cant display an image via PHP in wordpress
- Shortcode to pull posts
- PHP code inside Shortcode
- Help Fallback (thumbnail)
- How to return a string that has a jQuery and Ajax inside in a shortcode?
- Action Hook Inside WordPress Plugin Shortcode
- How can I include the user id inside of a shortcode php output?
- PHP Helper Class to create shortcodes
- help with custom shortcode that stopped working
- Change Spaces to Dashes?
- how to get sentence values from wordpress shortcode parameter?
- Updating Metadata with Shortcode
- using shortcodes inside gravity forms
- How to Create custom block for displaying information in content section which act like shortcode
- Create shortcode for metabox gallery
- couldnt show short code atts in category
- How can I edit the final HTML structure of the whole web page
- I am having an issue with this shortcode plugin.. Warning: Illegal string offset ‘title’
- Advanced Custom Forms PHP formatting for do_shortcode
- overwrite wordpress gallery with custom gallery shortcode
- How to use Contact Form 7 shortcode value in a page?
- How Can I Display the Last Modified Date for User Profiles on WordPress?
- CPT in a shortcode
- PHP/CSS: Shortcode won’t display correctly, and only displays in the head (before content)
- Show products per shortcode
- Open/closed function [closed]
- What is wrong with this shortcode? to include external php file in WordPress posts
- Need to Echo A Url path to show on a wordpress page
- WordPress Shortcode based on other shortcode
- Wrapping shortcode content in a span or link
- Formatting Shortcode to Display in Visual Mode
- Use html tags in shortcode_atts, is it real?
- How to pass parameter that ends up being part of a class name with wordpress shortcode
- How to have Function of a plugin using global vars into a shortcode?
- Overwriting a Shortcode
- Where to place PHP for shortcodes
- How to wrap a text with shortcode into php file?
- Whats wrong with my code? Need To add String to shortcode? [closed]
- A next page function with shortcode?
- using a shortcode in a hyperlink
- WP Custom tables query
- Display total count of products in orders of a specific order status
- Display terms on product page with shotrcode
- Redirect loop upon installation of my plugin
- why css file not link?how to create permalink?
- Custom plugin with shortcode not working
- Show Login Errors In WordPress/Elementor (Code “works”, but breaks site)
- Shortcode Displays 2 times
- Adding a css class to the gallery
- Strip and print only the numbers found in current’s post excerpt (even if they are without space)
- Woocomerce custom add to cart button edit functionality [closed]
- I have a php function with a shortcode to add share buttons, but I’m having an error!
- How to make this shortcode not refresh the whole page when i use it on frontend
- “Joined in” or “Member since” displayed on single store page and then using shortcode to add