/** * * * @since 1.0.0 * @access public * @param * @return void */ public function getPosts($post_type = 'post', $num = 3, $sort = 'date', $thumb = true, $excerpt_length = 40, $container = 'elr-col-third') { $query_helper = new Query(); $content_helper = new ContentHelper(); $query = $query_helper->postQuery($post_type, $num, $sort); if ($query->have_posts()) { $content = ''; while ($query->have_posts()) { $query->the_post(); global $post; $content .= '<div class="'; $content .= $container; $content .= '">'; $content .= '<div class="post-box post-box-'; $content .= strtolower(str_replace(' ', '-', $post_type)); $content .= '">'; if ($thumb) { $content .= '<figure class="post-box-image"><a href="'; $content .= get_the_permalink(); $content .= '">'; $content .= get_the_post_thumbnail(); $content .= '</a></figure>'; } $content .= '<h2 class="post-box-title"><a href="'; $content .= get_the_permalink(); $content .= '">'; $content .= get_the_title(); $content .= '</a></h2><p class="post-box-excerpt">'; $content .= esc_html($content_helper->trim_content($excerpt_length)); $content .= '</p><a href="'; $content .= get_the_permalink(); $content .= '" class="post-box-learn-more">Read More</a></div></div>'; } wp_reset_postdata(); return $content; } return null; }