I got this code to show my thumbnails images and videos on my blog page, but when i try to use to show the thumbs in another page, it doesnt works.
Function to display images and videos thumbs
function show_blog_posts() {
global $post, $blog, $posts;
$first_vid = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<iframe.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$first_vid = $matches [1] [0];
if ($output == '1') {
echo '<iframe width="100%" height="400" src="';
echo $first_vid;
echo '" frameborder="0" allowfullscreen></iframe>';
} else { ?>
<?php the_post_thumbnail('large');?>
My shortcode
add_shortcode('recent_blog_posts', 'shortcode_recent_blog_posts');
function shortcode_recent_blog_posts($atts) {
$str = '';
$args = array( 'numberposts' => 3, 'post_status'=>"publish",'post_type'=>"post",'orderby'=>"post_date");
$postslist = get_posts( $args );
foreach ($postslist as $post) : setup_postdata($post);
$str .= '<div id ="article-section-box2" class="span3">';
$str .= '<div id= "image1" class="image-arcticle">';
$str .= show_blog_posts($post->ID, '');
$str .= '</div>';
$str .='<p class="article_text">'.excerpt(18).'</p>';
$str .='</div>';
endforeach;
return $str;
Is there anything wrong? Thanks