';
while ( $post->have_posts() ) {
$post->the_post();
$item_index ++;
/**
* Based on the post index, decide if the post should display full width or just 50% of the page. If it's
* the only post, display it as full width.
*/
$card_class = $this->get_card_class( $item_index, $total_posts );
$card_inner_class = 'card card-raised';
/**
* If the post has a thumbnail, we add the class card-background which adds overlay on the image, center
* the content and change the color of the text.
*/
$thumb_style = '';
if ( has_post_thumbnail() ) {
$card_inner_class .= ' card-background';
$thumb_url = get_the_post_thumbnail_url();
$thumb_style = 'style="background-image:url(' . esc_url( $thumb_url ) . ')"';
}
// Get the data (title, category, content) and display the post.
$pid = get_the_ID();
array_push( $this->posts_to_skip, $pid );
$post_url = esc_url( get_permalink() );
$title = get_the_title();
$content = get_the_excerpt();
$content = preg_replace( '/
(.*?)<\/a>/i', '...', $content );
echo '';
echo '';
echo '';
}
wp_reset_postdata();
echo ' ';
}
/**
* Filter main loop posts for featured area exclusion.
*
* @param array $posts the posts array.
*
* @return array
*/
public function remove_featured_posts_in_main_loop( $posts ) {
return array_merge( $posts, $this->posts_to_skip );
}
/**
* Based on the post index, decide if the post should display full width or just 50% of the page.
*
* @param int $index Post index.
* @param int $total_posts Number of posts in category.
*
* @return string
*/
private function get_card_class( $index, $total_posts ) {
if ( $total_posts > 1 ) {
if ( $index % 3 === 1 ) {
return 'col-md-6';
}
if ( $index % 3 === 2 ) {
return 'col-md-6';
}
return 'col-md-12';
}
}
/**
* Featured posts wrapper class.
*
* @return string
*/
private function wrapper_class() {
$default = hestia_get_blog_layout_default();
$blog_sidebar_layout = apply_filters( 'hestia_sidebar_layout', get_theme_mod( 'hestia_blog_sidebar_layout', $default ) );
if ( $blog_sidebar_layout === 'full-width' || ( ! is_active_sidebar( 'sidebar-1' ) && ! is_customize_preview() ) ) {
return ' col-md-10 col-md-offset-1 ';
} else {
return ' col-md-12 ';
}
}
}