'3', 'type' => 'top', 'per_page' => '5', 'link_text' => '', ); $args = wp_parse_args($atts, $defaults); $per_page = ($args['type'] == "bottom") ? 5 : $args['type']; $args1 = array( 'post_type' => 'post', 'posts_per_page' => $args['per_page'], 'order' => 'desc' ); $loop = new WP_Query($args1); $news_item = ""; if ($loop->have_posts()) { if ($args['type'] == "bottom") { $news_item .=''; } else { $news_item .='
'; while($loop->have_posts()) { $loop->the_post(); $news_author_name = esc_html( get_post_meta( get_the_ID(), 'news_author_name', true ) ); $contents = wp_trim_words( get_the_content(), 25 ); $img = get_the_post_thumbnail_url('','full'); $img = ($img=="") ? get_template_directory_uri(). '/fst-framework/fst-customizer/assets/images/default-img.png' : $img; $fst_column_class = 'col-xl-4 col-lg-4 col-md-6'; if ($args['column'] == 4) { $fst_column_class = 'col-xl-3 col-lg-3 col-md-6'; } elseif ($args['column'] == 2) { $fst_column_class = 'col-xl-6 col-lg-6 col-md-6'; } elseif ($args['column'] == 1) { $fst_column_class = 'col-xl-12 col-lg-12 col-md-12'; } ob_start(); get_template_part('template-parts/addons/news/posts'); $fst_bottom_post_contents = ob_get_clean(); $replace = array('{{image}}','{{heading}}','{{author}}','{{date}}','{{content}}', '{{link_text}}','{{permalink}}','{{column_class}}'); $to = array(esc_url($img),get_the_title(),get_the_author(),get_the_date( "F d, Y" ), strip_tags($contents),$args['link_text'],get_post_permalink(),$fst_column_class); $news_item .= str_replace($replace,$to, $fst_bottom_post_contents); } wp_reset_query(); $news_item .='
'; } } return $news_item; } }