Keep Reading...
$count=0; if( have_rows('select_post') ): // loop through the rows of data while ( have_rows('select_post') ) : the_row(); $count++; // display a sub field value $a=get_sub_field('the_post'); echo "";
echo get_the_post_thumbnail( $a->ID, 'tiny' );
if(get_the_post_thumbnail( $a->ID)==false) {
main_image($a->ID);
}
echo "
";
/*
WP_Post Object
(
[ID] => 4061
[post_title]
[post_excerpt]
[guid] => https://www.videouniversity.com/?p=4061
)
*/
endwhile;
else :
// no rows found
endif;
$needed= 4-$count;
if($needed>=1) {
$cat=array();
$categories = get_categories( $args );
//echo "";
echo "";
$page_data = get_page( $a->ID );
$excerpt = strip_tags($page_data->post_excerpt);
echo $excerpt;
echo "Read More";
echo "
";
echo "";
echo ""; print_r($categories); echo ""; foreach($categories as $c) { $term_id= $c->term_id; if($term_id!=1){ array_push($cat, $term_id); } } // WP_Query arguments $args = array ( 'post_type' => array('post','page','shop','article'), 'orderby' => 'rand', 'posts_per_page' => $needed, 'cat'=>$cat, 'meta_query' => array(array('key' => '_thumbnail_id')) ); // The Query $query = new WP_Query( $args ); // The Loop if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); ?>
echo get_the_post_thumbnail( get_the_id(), 'tiny' );
if(get_the_post_thumbnail( get_the_id())==false) {
main_image(get_the_id());
}
?>
}
} else {
// no posts found
}
// Restore original Post Data
wp_reset_postdata();
}
?>