‘);
echo($post_media.’
$args = array(
‘numberposts’ => 1,
‘offset’ => 0,
‘category’ => $category->cat_ID,
‘orderby’ => ‘post_date’,
‘order’ => ‘DESC’,
‘post_type’ => ‘post’,
‘post_status’ => ‘publish’,
‘suppress_filters’ => true );
$catlink = get_category_link( $category->cat_ID );
$recent_posts = wp_get_recent_posts( $args, ARRAY_A );
foreach( $recent_posts as $recent ){
$blog_image = wp_get_attachment_image(get_post_thumbnail_id($recent[‘ID’]), ‘full’);
$blog_image_url = wp_get_attachment_url(get_post_thumbnail_id($recent[‘ID’]));
$post_format = get_post_format($recent[‘ID’]);
$gallery = get_post_meta($recent[‘ID’], ‘post_gallery_image’, true);
$gallery = explode(‘,’, $gallery);
$icon = ”;
$post_media = ”;
switch($post_format) {
case ‘gallery’:
$icon = ‘‘;
break;
case ‘video’:
$icon = ‘‘;
break;
default:
$icon = ‘‘;
}
if ($post_format === ‘video’) {
// get post video
$video = ”;
$video_custom_meta = get_post_meta($recent[‘ID’], ‘post_video’, true);
if ( !empty($video_custom_meta) ) {
$video = $video_custom_meta;
}
if ( !empty($video) ) {
$post_media =
‘
‘;
}
}
elseif ($post_format === ‘gallery’) {
$images = array();
$uniqueId = rand(1000, 9999);
$index = 0;
foreach($gallery as $image) {
$fullImage = $image;
$active = $index === 0 ? ‘ active’ : ”;
$post_thumbnail = ‘-270×230’;
$image = explode(‘.’, $image);
$imageExtension = $image[count($image) – 1];
unset($image[count($image) – 1]);
$image = implode(‘.’, $image);
$imageName = $image . $post_thumbnail . ‘.’ . $imageExtension;
$images[] = ‘
‘;
$index++;
}
if ( !empty($images) ) {
$post_media =
‘
‘;
}
}
else {
if ( !empty($blog_image) ) {
$post_media =
‘
‘;
}
}
if ( empty($post_media) ) {
$post_media = ‘
‘;
}
//print_r($recent);
// get_post ($recent[‘ID’]);
$excerpt = substr($recent[‘post_content’],0,150);
$alink = get_post_permalink($recent[‘ID’]);
$title = get_the_title( $recent[‘ID’] );
$count = $count + 1;
echo(‘
‘);
echo($post_media.’
‘);
}
}
echo(“
“);
[/insert_php]