I have a function which is used to display a video, I want this video to be shown after the post, It should display the video when the post ends.
I have added filter to it, but then too, the video is shown before the post.
Here is the filter which I am using:
function append_the_video($content) {
global $post;
$content .= youtube_video();
return $content;
}
add_filter('the_content', 'append_the_video');
edited entire function
<?php
function youtube_video()
{
?>
<div class="post">
<?php
$newvar = urlencode(get_the_title());
include_once(ABSPATH . WPINC . '/rss.php');
$rss = fetch_rss('http://gdata.youtube.com/feeds/base/videos?q='.$newvar.'&client=ytapi-youtube-search&v=2');
$maxitems = get_option('novideos');
$items =is_array($rss->items) ? array_slice($rss->items, 0, $maxitems) : '' ;
?>
<ul>
<?php if (empty($items)) {echo "No current video uploads by ".get_the_title();}
else foreach ( $items as $item ) : ?>
<?php
$youtubeid = strchr($item['link'],'=');
$youtubeid = substr($youtubeid,1);
?>
<p>Latest Videos of <b><?php the_title(); ?>:</b></p>
<br>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="320" height="265">
<param name="movie" value="http://www.youtube.com/v/<?php echo $youtubeid ?>&hl=en&fs=1" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="http://www.youtube.com/v/<?php echo $youtubeid ?>&hl=en&fs=1" width="320" height="265">
<!--<![endif]-->
<p><a href="http://www.youtube.com/v/<?php echo $youtubeid ?>">View movie»</a></p>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php
}
function append_the_video($content) {
global $post;
$content .= youtube_video();
return $content;
}
add_filter('the_content', 'append_the_video');
?>