function latest_post($atts, $content = null) { $html = ""; extract(shortcode_atts(array("post_number" => "", "order_by" => "", "order" => "", "category" => "", "text_length" => ""), $atts)); $q = new WP_Query(array('orderby' => $order_by, 'order' => $order, 'posts_per_page' => $post_number, 'category_name' => $category)); $html .= "<div class='latest_post_holder'><ul>"; while ($q->have_posts()) { $q->the_post(); $html .= '<li class="'; if ($post_number == 2) { $html .= 'two'; } else { if ($post_number == 3) { $html .= 'three'; } else { if ($post_number == 4) { $html .= 'four'; } else { if ($post_number == 5) { $html .= 'five'; } } } } if ($text_length > 0) { $html .= '"><div class="latest_post"><a href="' . get_permalink() . '">' . get_the_post_thumbnail(get_the_id(), 'full') . '</a><div class="latest_post_text"><h3><a href="' . get_permalink() . '">' . get_the_title() . '</a></h3>' . '<p>' . substr(get_the_excerpt(), 0, intval($text_length)) . '...</p><span>' . get_post_time('d M Y') . '</span></div></div>'; $html .= '<div class="latest_post_bottom"><div class="latest_post_like">'; if (function_exists('qode_like')) { $html .= qode_like_latest_posts() . '</div>'; $html .= do_shortcode('[social_share]'); } $html .= '</div></li>'; } else { $html .= '"><div class="latest_post"><a href="' . get_permalink() . '">' . get_the_post_thumbnail(get_the_id(), 'full') . '</a><div class="latest_post_text"><h3><a href="' . get_permalink() . '">' . get_the_title() . '</a></h3><span>' . get_post_time('d M Y') . '</span></div></div>'; $html .= '<div class="latest_post_bottom"><div class="latest_post_like">'; if (function_exists('qode_like')) { $html .= qode_like_latest_posts() . '</div>'; $html .= do_shortcode('[social_share]'); } $html .= '</div></li>'; } } wp_reset_query(); $html .= "</ul></div>"; return $html; }
function latest_post($atts, $content = null) { $blog_hide_comments = ""; if (isset($qode_options_proya['blog_hide_comments'])) { $blog_hide_comments = $qode_options_proya['blog_hide_comments']; } $qode_like = "on"; if (isset($qode_options_proya['qode_like'])) { $qode_like = $qode_options_proya['qode_like']; } $args = array("type" => "date_in_box", "number_of_posts" => "", "number_of_colums" => "", "number_of_rows" => "1", "text_from_edge" => "", "rows" => "", "order_by" => "", "order" => "", "category" => "", "text_length" => "", "title_tag" => "h5", "display_category" => "0", "display_time" => "1", "display_comments" => "1", "display_like" => "0", "display_share" => "0"); extract(shortcode_atts($args, $atts)); $headings_array = array('h2', 'h3', 'h4', 'h5', 'h6'); //get correct heading value. If provided heading isn't valid get the default one $title_tag = in_array($title_tag, $headings_array) ? $title_tag : $args['title_tag']; if ($type != "boxes" && $type != "dividers") { $q = new WP_Query(array('orderby' => $order_by, 'order' => $order, 'posts_per_page' => $number_of_posts, 'category_name' => $category)); } else { $q = new WP_Query(array('orderby' => $order_by, 'order' => $order, 'posts_per_page' => $number_of_colums * $number_of_rows, 'category_name' => $category)); } $columns_number = ""; if ($type == 'boxes' || $type == 'dividers') { if ($number_of_colums == 2) { $columns_number = "two_columns"; } else { if ($number_of_colums == 3) { $columns_number = "three_columns"; } else { if ($number_of_colums == 4) { $columns_number = "four_columns"; } } } } //get number of rows class for boxes type $rows_number = ""; if ($type == 'boxes' || $type == 'dividers') { switch ($number_of_rows) { case 1: $rows_number = 'one_row'; break; case 2: $rows_number = 'two_rows'; break; case 3: $rows_number = 'three_rows'; break; case 4: $rows_number = 'four_rows'; break; case 5: $rows_number = 'five_rows'; break; default: break; } } $html = ""; $html .= "<div class='latest_post_holder {$type} {$columns_number} {$rows_number}'>"; $html .= "<ul>"; while ($q->have_posts()) { $q->the_post(); $li_classes = ""; $cat = get_the_category(); $html .= '<li class="clearfix">'; if ($type == "date_in_box") { $html .= '<div class="latest_post_date">'; $html .= '<div class="post_publish_day">' . get_the_time('d') . '</div>'; $html .= '<div class="post_publish_month">' . get_the_time('M') . '</div>'; $html .= '</div>'; } if ($type == "boxes" || $type == 'dividers') { $html .= '<div class="boxes_image">'; $html .= '<a href="' . get_permalink() . '">' . get_the_post_thumbnail(get_the_ID(), 'latest_post_boxes') . '</a>'; $html .= '</div>'; } $padding_latest_post = ""; if ($text_from_edge == "yes" && $type == "boxes") { $padding_latest_post = " style='padding-left:0;padding-right:0;'"; } $html .= '<div class="latest_post"' . $padding_latest_post . '>'; if ($type == "image_in_box") { $html .= '<div class="latest_post_image clearfix">'; $featured_image_array = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail'); $html .= '<img src="' . $featured_image_array[0] . '" alt="" />'; $html .= '</div>'; } $html .= '<div class="latest_post_text">'; $html .= '<div class="latest_post_inner">'; if ($type == "dividers") { $html .= '<div class="latest_post_date">'; $html .= '<div class="latest_post_day">' . get_the_time('d') . '</div>'; $html .= '<div class="latest_post_month">' . get_the_time('M') . '</div>'; $html .= '</div>'; } $html .= '<div class="latest_post_text_inner">'; if ($type != "minimal") { $html .= '<' . $title_tag . ' class="latest_post_title "><a href="' . get_permalink() . '">' . get_the_title() . '</a></' . $title_tag . '>'; } if ($type != "minimal") { if ($text_length != '0') { $excerpt = $text_length > 0 ? mb_substr(get_the_excerpt(), 0, intval($text_length)) : get_the_excerpt(); $html .= '<p class="excerpt">' . $excerpt . '...</p>'; } } $html .= '<span class="post_infos">'; if ($display_time == '1' && $type !== 'dividers') { $html .= '<span class="date_hour_holder">'; if ($type != 'date_in_box') { $html .= '<span class="date">' . get_the_time('d F, Y') . '</span>'; } else { $html .= '<span class="date">' . get_the_time('g:h') . 'h</span>'; } $html .= '</span>'; //close date_hour_holder } if ($display_category == '1') { if ($type == "dividers") { foreach ($cat as $categ) { $html .= '<a href="' . get_category_link($categ->term_id) . '">' . $categ->cat_name . '</a>'; } } else { $html .= '<span class="dots"><i class="fa fa-square"></i></span>'; foreach ($cat as $categ) { $html .= ' <a href="' . get_category_link($categ->term_id) . '">' . $categ->cat_name . ' </a> '; } } } //generate comments part of description if ($blog_hide_comments != "yes" && $display_comments == "1") { $comments_count = get_comments_number(); switch ($comments_count) { case 0: $comments_count_text = __('No comment', 'qode'); break; case 1: $comments_count_text = $comments_count . ' ' . __('Comment', 'qode'); break; default: $comments_count_text = $comments_count . ' ' . __('Comments', 'qode'); break; } if ($type != "dividers") { $html .= '<span class="dots"><i class="fa fa-square"></i></span>'; } $html .= '<a class="post_comments" href="' . get_comments_link() . '">'; $html .= $comments_count_text; $html .= '</a>'; //close post_comments } if ($qode_like == "on" && function_exists('qode_like')) { if ($display_like == '1') { if ($type != "dividers") { $html .= '<span class="dots"><i class="fa fa-square"></i></span>'; } $html .= '<span class="blog_like">' . qode_like_latest_posts() . '</span>'; } } if ($display_share == '1') { if ($type != "dividers") { $html .= '<span class="dots"><i class="fa fa-square"></i></span>'; } $html .= do_shortcode('[social_share]'); } $html .= '</span>'; //close post_infos span if ($type == "minimal") { $html .= '<' . $title_tag . ' class="latest_post_title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></' . $title_tag . '>'; } $html .= '</div>'; //close latest_post_text_inner span $html .= '</div>'; //close latest_post_inner div $html .= '</div>'; //close latest_post_text div $html .= '</div>'; //close latest_post div } wp_reset_postdata(); $html .= "</ul></div>"; return $html; }
function latest_post($atts, $content = null) { $blog_hide_comments = ""; if (isset($qode_options_river['blog_hide_comments'])) { $blog_hide_comments = $qode_options_river['blog_hide_comments']; } $qode_like = "on"; if (isset($qode_options_river['qode_like'])) { $qode_like = $qode_options_river['qode_like']; } $args = array("post_number_per_row" => "", "rows" => "", "order_by" => "", "order" => "", "category" => "", "text_length" => "", "title_tag" => "h4"); extract(shortcode_atts($args, $atts)); $headings_array = array('h2', 'h3', 'h4', 'h5', 'h6'); //get correct heading value. If provided heading isn't valid get the default one $title_tag = in_array($title_tag, $headings_array) ? $title_tag : $args['title_tag']; $q = new WP_Query(array('orderby' => $order_by, 'order' => $order, 'posts_per_page' => $post_number_per_row * $rows, 'category_name' => $category)); $html = ""; $html .= "<div class='latest_post_holder'>"; $html .= "<ul>"; while ($q->have_posts()) { $q->the_post(); $li_classes = ""; $cat = get_the_category(); if ($post_number_per_row == 2) { $li_classes .= 'two '; } else { if ($post_number_per_row == 3) { $li_classes .= 'three'; } else { if ($post_number_per_row == 4) { $li_classes .= 'four'; } } } $html .= '<li class="' . $li_classes . '">'; $html .= '<div class="latest_post">'; $html .= '<a href="' . get_permalink() . '" class="latest_post_wrapper">' . get_the_post_thumbnail(get_the_id(), 'full') . '</a>'; //get post thumbnail $html .= '<div class="latest_post_text">'; $html .= '<div class="latest_post_inner">'; $html .= '<span class="post_infos">'; $html .= '<span class="date">' . get_post_time('d') . ' </span>'; $html .= '<span class="month">' . get_post_time('F') . ' </span>'; $html .= '<span class="latest-vert-separator"> | </span>'; foreach ($cat as $categ) { $html .= ' <a href="' . get_category_link($categ->term_id) . '">' . $categ->cat_name . ' </a> '; } $html .= '<span class="latest-vert-separator"> | </span>'; $html .= '<a class="post_author" href="' . get_author_posts_url(get_the_author_meta('ID')) . '">' . get_the_author_meta('display_name') . ' </a>'; //generate comments part of description if ($blog_hide_comments != "yes") { $comments_count = get_comments_number(); switch ($comments_count) { case 0: $comments_count_text = __('No comment', 'qode'); break; case 1: $comments_count_text = $comments_count . ' ' . __('Comment', 'qode'); break; default: $comments_count_text = $comments_count . ' ' . __('Comments', 'qode'); break; } $html .= '<span class="latest-vert-separator"> | </span>'; $html .= '<a class="post_comments" href="' . get_comments_link() . '">' . $comments_count_text . '</a>'; } $html .= '</span>'; //close post_infos span $html .= '<' . $title_tag . ' class="latest_post_title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></' . $title_tag . '>'; $html .= '</div>'; //close latest_post_inner div if ($text_length > 0) { $html .= '<p>' . substr(get_the_excerpt(), 0, intval($text_length)) . '...</p>'; } $html .= '<span class="post_social">'; //generate qode like part if ($qode_like == "on") { $html .= '<span class="blog_like">'; if (function_exists('qode_like_latest_posts')) { $html .= qode_like_latest_posts(); } $html .= '</span>'; } //why is this called? do_shortcode('[social_share]'); $html .= '</span>'; //close post_social $html .= '</div>'; //close latest_post_text div $html .= '</div>'; //close latest_post div } wp_reset_query(); $html .= "</ul></div>"; return $html; }