Last active
November 23, 2015 11:16
-
-
Save somaria/2deaef0ad3048d4cbcea to your computer and use it in GitHub Desktop.
Display Youtube Link in WP Post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*Display Youtube Link*/ | |
| add_filter('the_content', 'add_my_content'); | |
| function add_my_content($content) { | |
| $my_custom_text = get_post_meta(get_the_ID(), 'youtube_link', $single = true); | |
| $embed_code = wp_oembed_get($my_custom_text, array('width'=>720, 'height'=>420)); | |
| if ($my_custom_text) { | |
| $content .= $embed_code; | |
| $content .= '<p></p>'; | |
| } | |
| return $content; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment