Echo do shortcode with custom field not working
the_field() prints the value, it doesn’t return the string, so you cannot use it in a variable. Use … $video = get_field(“video_file”); … instead.
the_field() prints the value, it doesn’t return the string, so you cannot use it in a variable. Use … $video = get_field(“video_file”); … instead.
Shortcode functions accept a second parameter which contains the value in between the shortcode opening and closing tags: function youtube( $atts, $value=”http://” ) { extract( shortcode_atts( array( “width” => ‘620’, “height” => ‘350’, “name”=> ‘movie’, “allowFullScreen” => ‘true’, “allowScriptAccess”=>’always’, ), $atts ) ); return ‘<object style=”height: ‘.$height.’px; width: ‘.$width.’px”><param name=”‘.$name.'” value=”‘.$value.'”><param name=”allowFullScreen” value=”‘.$allowFullScreen.'”></param><param name=”allowScriptAccess” value=”‘.$allowScriptAccess.'”></param><embed … Read more
Just add the comments to oEmbed. Here’s a small plugin that you can use as MU-Plugin or normal plugin and that should explain what’s going on pretty well. <?php defined( ‘ABSPATH’ ) or exit; /* Plugin Name: (#105942) oEmbed Comments */ add_filter( ‘comment_text’, ‘wpse_105942_oembed_comments’, 0 ); function wpse_105942_oembed_comments( $comment ) { add_filter( ’embed_oembed_discover’, ‘__return_false’, 999 … Read more
Problem is here: <div id=”my-video” style=”display:none;”> as you can see, id is static and is the same for all posts. First of all this is not compliant with html standard: tag id must be unique. As a side effect if you use the id selector in jquery and the id is used a lot of … Read more
I’m not sure why that’s not working except maybe you need to put the returned stuff in a variable? This is what works for me when I put it in my functions.php file: add_filter( ’embed_oembed_html’, ‘tdd_oembed_filter’, 10, 4 ) ; function tdd_oembed_filter($html, $url, $attr, $post_ID) { $return = ‘<figure class=”video-container”>’.$html.'</figure>’; return $return; }
Welcome to WordPress StackExchange. This is really an HTML/CSS question rather than a WordPress specific one, so you will have better luck getting a quick answer in the future by posting to another StackExchange site, such as Stack Overflow. However, your issue should be fixed if you set a percent as the width, rather than … Read more
There may be a more graceful way to do this, but it works: function shortcode_youtube($atts) { extract(shortcode_atts(array( “id” => ”, “align” => ‘aligncenter’ ), $atts)); global $wp_embed; $content=”‘; $embed = $wp_embed->run_shortcode( $content ); return ‘<div class=”‘.$align.'”>’ . $embed . ‘</div>’; } add_shortcode(“youtube”, “shortcode_youtube”);
The plugin uses cURl direkt instead of WordPress’ built in HTTP class. If your sever does not support cURL, the plugin can not work and you got this message. Deinstall the plugin and use another one. Or replace the curl_it() function within the plugin with something stable. Update The workaraound: Open the plugin file youtube-sidebar-widget.php … Read more
You can for example: Copy the YouTube shortcode from the old theme to your new theme. Locate the line (most likely in the functions.php file): add_shortcode( ‘youtube’, ‘some_function’ ); and copy this line and the some_function() to your functions.php in your new theme or better yet – create a new plugin file including: /*Plugin Name: … Read more
Did you know you can just copy paste a youtube URL onto its own line and it transforms into a video player auto-magically via oembed? There’s no need for embed codes/shortcodes/plugins Simply create a blank line, and take the address of the youtube video and paste it into the editor: These youtube videos should not … Read more