function tfuse_latest_reviews($atts, $content = null) { extract(shortcode_atts(array('title' => '', 'items' => ''), $atts)); $query = new WP_Query(array('post_type' => 'review', 'orderby' => 'post_date', 'order ' => 'DESC', 'posts_per_page' => $items)); $posts = $query->get_posts(); $return_html = $img = ''; if (!empty($posts)) { $return_html .= '<div class="widget widget_recent_entries"> <h3 class="widget-title">Latest Reviews</h3> <ul class="side-postlist">'; foreach ($posts as $post) { $post_image_src = wp_get_attachment_url(get_post_thumbnail_id($post->ID, 'post-thumbnails')); if (!empty($post_image_src)) { $get_image = new TF_GET_IMAGE(); $img = $get_image->properties(array('class' => '', 'alt' => get_the_title($post->ID)))->width(62)->height(62)->src($post_image_src)->resize(true)->get_img(); } $return_html .= '<li>'; if (!empty($img)) { $return_html .= '<a href="' . get_permalink($post->ID) . '" class="post-thumbnail"> ' . $img . ' </a>'; } $return_html .= '<a href="' . get_permalink($post->ID) . '" class="post-title">' . get_the_title($post->ID) . '</a> <span class="comments-link"><a href="' . get_permalink($post->ID) . '#comments">' . tfuse_get_comments(true, $post->ID) . '</a></span> </li>'; } $return_html .= '</ul> </div>'; } return $return_html; }
/** * Generate array with: recent/popular/most commented posts * @param string $sort Sort type (recent/popular/most commented) * @param integer $items Number of items to be extracted * @param boolean $image_post Extract or no post image * @param integer $image_width Set width of post image * @param integer $image_height Set height of post image * @param string $image_class Set class of post image * @param boolean $date_post Extract or no post date * @param string $date_format Set date format * @param string $post_type Set post type * @param string $category Set category from where posts would be extracted * @since Medica 2.0 */ function tfuse_shortcode_posts($args = null) { $defaults = array('sort' => 'recent', 'items' => 5, 'image_post' => true, 'image_width' => 54, 'image_height' => 54, 'image_class' => 'thumbnail', 'date_post' => true, 'date_format' => 'F jS, Y', 'post_type' => 'post', 'category' => '', 'specialites' => ''); extract(wp_parse_args($args, $defaults)); global $post; $tf_cat_ID = !empty($category) && empty($specialites) ? get_cat_ID($category) : ''; $specialites = empty($category) && !empty($specialites) ? $specialites : ''; if ($sort == 'recent') { $query = new WP_Query(array('post_type' => $post_type, 'orderby' => 'post_date', 'order ' => 'DESC', 'cat' => $tf_cat_ID, 'Specialites' => $specialites, 'posts_per_page' => $items)); $posts = $query->get_posts(); } elseif ($sort == 'popular') { $query = new WP_Query(array('post_type' => $post_type, 'orderby' => 'meta_value', 'meta_key' => TF_THEME_PREFIX . '_post_viewed', 'order ' => 'DESC', 'cat' => $tf_cat_ID, 'posts_per_page' => $items)); $posts = $query->get_posts(); } elseif ($sort == 'commented') { $query = new WP_Query(array('post_type' => $post_type, 'orderby' => 'comment_count', 'order ' => 'DESC', 'cat' => $tf_cat_ID, 'posts_per_page' => $items)); $posts = $query->get_posts(); } else { return false; } $tf_post_option = array(); $count = 0; if (!empty($posts)) { foreach ($posts as $post_elm) { setup_postdata($post_elm); $img = ''; if ($image_post == true) { $post_image_src = tfuse_page_options('thumbnail_image', tfuse_page_options('single_image', null, $post_elm->ID), $post_elm->ID); if (!empty($post_image_src)) { $get_image = new TF_GET_IMAGE(); $img = $get_image->properties(array('class' => $image_class, 'alt' => get_the_title($post_elm->ID)))->width($image_width)->height($image_height)->src($post_image_src)->resize(true)->get_img(); } } if (!empty($img)) { $tf_post_option[$count]['post_img'] = $img; } else { $tf_post_option[$count]['post_img'] = ''; } if ($date_post) { $time_format = apply_filters('tfuse_widget_time_format', $date_format); $tf_post_option[$count]['post_date_post'] = get_the_time($time_format, $post_elm->ID); } else { $tf_post_option[$count]['post_date_post'] = ''; } $tf_post_option[$count]['post_class'] = is_singular() && $post->ID == $post_elm->ID ? 'current-menu-item post_' . $sort : 'post_' . $sort; $tf_post_option[$count]['post_title'] = get_the_title($post_elm->ID); $tf_post_option[$count]['post_link'] = get_permalink($post_elm->ID); $tf_post_option[$count]['post_author_link'] = get_author_posts_url(get_the_author_meta('ID')); $tf_post_option[$count]['post_author_name'] = get_the_author(); $tf_post_option[$count]['post_comnt_numb'] = get_comments_number($post_elm->ID); $tf_post_option[$count]['post_comnt_numb_link'] = tfuse_get_comments(true, $post_elm->ID); $tf_post_option[$count]['post_loveit_number'] = get_post_meta($post_elm->ID, TF_THEME_PREFIX . '_post_viewed', true); $tf_post_option[$count]['post_excerpt'] = apply_filters('get_the_excerpt', $post_elm->post_excerpt); $count++; } wp_reset_postdata(); } return $tf_post_option; }
/** * MG Fresh Posts * * To override this shortcode in a child theme, copy this file to your child theme's * theme_config/extensions/shortcodes/shortcodes/ folder. * */ function tfuse_fresh_posts($atts, $content = null) { remove_filter('excerpt_length', 'tfuse_custom_excerpt_length'); add_filter('excerpt_length', 'tfuse_custom_excerpt_length_short', 99); extract(shortcode_atts(array('title' => '', 'posts' => ''), $atts)); $output = ''; if (!empty($posts)) { $posts = explode(',', $posts); $output .= '<div class="widget-container widget_featured_posts">'; if (!empty($title)) { $output .= '<h3 class="widget-title">' . tfuse_qtranslate($title) . '</h3>'; } $output .= '<ul>'; $posts = get_posts(array('post__in' => $posts)); if (!empty($posts)) { foreach ($posts as $post) { if (has_post_thumbnail($post->ID)) { $src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), '', false, ''); $post_image_src = $src[0]; } else { $post_image_src = ''; } $image = new TF_GET_IMAGE(); $image->removeSizeParams = true; $img = $image->properties(array('class' => 'thumbnail'))->width(262)->height(85)->src($post_image_src)->get_img(); $link = get_permalink($post->ID); $output .= '<li class="post-item"> <div class="post-title"><a href="' . $link . '">' . $post->post_title . '</a></div> <div class="post-meta">' . __('written by ', 'tfuse') . '<span class="post-author"><a href="' . get_author_posts_url($post->post_author) . '" title="Posts by">' . get_the_author() . '</a></span></div> <div class="post-image"><a href="' . $link . '">' . $img . '</a></div> <div class="post-descr">' . $post->post_excerpt . '</div> <div class="post-more"><a href="' . $link . '">' . __('READ THE ARTICLE', 'tfuse') . '</a></div> </li>'; } } $output .= '</ul></div>'; } return $output; }
function tfuse_shortcode_latest_post($atts, $content = null) { $out = ''; $recent_post = wp_get_recent_posts(array('numberposts' => 1)); if (!empty($recent_post)) { foreach ($recent_post as $post) { $image = wp_get_attachment_url(get_post_thumbnail_id($post['ID'], 'post-thumbnails')); $get_image = new TF_GET_IMAGE(); $img = $get_image->properties(array('class' => '', 'alt' => get_the_title($post['ID'])))->width(210)->height(82)->src($image)->resize(true)->get_img(); $current_post = get_post($post['ID']); $user_data = get_user_by('id', $current_post->post_author); $out .= '<article class="post"> <h2 class="entry-title"><a href="' . get_permalink($post['ID']) . '">' . get_the_title($post['ID']) . '</a></h2> <div class="entry-meta"> <time class="entry-date" datetime="">' . get_the_time(get_option('date_format'), $post['ID']) . '</time> <span class="author"> ' . __('by', 'tfuse') . ' <a href="' . get_author_posts_url($current_post->post_author, $user_data->data->user_nicename) . '">' . $user_data->data->user_nicename . '</a></span> </div> <span class="post-thumbnail">'; if (!empty($image)) { $out .= $img; } $out .= '</span> <div class="entry-content"><p>'; if (tfuse_options('post_content') == 'content') { $out .= $current_post->post_content; } else { $out .= !empty($current_post->post_excerpt) ? $current_post->post_excerpt : strip_tags(tfuse_shorten_string(apply_filters('the_content', $current_post->post_content), 150)); } $out .= '</p></div> <footer class="entry-meta"> <a href="' . get_permalink($post['ID']) . '" class="btn btn-yellow"><span>' . __('find out more', 'tfuse') . '</span></a> </footer> </article>'; } } return $out; }
/** * * Note that this function is hooked into the after_setup_theme hook, which runs * before the init hook. The init hook is too late for some features, such as indicating * support post thumbnails. * * To override tfuse_slider_type() in a child theme, add your own tfuse_slider_type to your child theme's * functions.php file. */ function tfuse_get_slides_from_posts($posts = array(), $slider = array()) { global $post; $slides = array(); $slider_image_resize = isset($slider['general']['slider_image_resize']) && $slider['general']['slider_image_resize'] == 'true' ? $slider['general']['slider_image_resize'] : false; $k = 0; foreach ($posts as $k => $post) { $k++; setup_postdata($post); $tfuse_image = $image = null; $image = new TF_GET_IMAGE(); if ($slider_image_resize) { $post_image_src = wp_get_attachment_url(get_post_thumbnail_id($post->ID, 'post-thumbnails')); $get_image = new TF_GET_IMAGE(); $tfuse_image = $get_image->properties(array('class' => '', 'alt' => get_the_title($post->ID)))->width(629)->height(500)->src($post_image_src)->resize(true)->get_img(); } else { $tfuse_image = '<img src="' . wp_get_attachment_url(get_post_thumbnail_id($post->ID, 'post-thumbnails')) . '"/>'; } } wp_reset_postdata(); return $slides; }
function tfuse_shortcode_latest_entry($atts, $content = null) { $out = ''; $recent_post = wp_get_recent_posts(array('numberposts' => 1)); if (!empty($recent_post)) { foreach ($recent_post as $post) { $image = wp_get_attachment_url(get_post_thumbnail_id($post['ID'], 'post-thumbnails')); $get_image = new TF_GET_IMAGE(); $img = $get_image->properties(array('class' => '', 'alt' => get_the_title($post['ID'])))->width(210)->height(210)->src($image)->resize(true)->get_img(); $current_post = get_post($post['ID']); $out .= ' <div class="home-post"> <div class="inner"> <div class="entry-aside"> <header class="entry-header"> <div class="entry-meta"> <div class="cat-links"> <a href="' . get_permalink($post['ID']) . '">' . __('Latest blog entry', 'tfuse') . '</a> </div> <time class="entry-date"><i class="icon-circle"></i>' . get_the_time(get_option('date_format'), $post['ID']) . '</time> <h1 class="entry-title"> <a href="' . get_permalink($post['ID']) . '">' . get_the_title($post['ID']) . '</a> </h1> </div> </header>'; if (!empty($image)) { $out .= '<a class="post-thumbnail" href="' . get_permalink($post['ID']) . '">' . $img . '</a>'; } $out .= '<div class="entry-content"> <p>'; if (tfuse_options('post_content') == 'content') { $out .= $current_post->post_content; } else { $out .= !empty($current_post->post_excerpt) ? $current_post->post_excerpt : strip_tags(tfuse_shorten_string(apply_filters('the_content', $current_post->post_content), 150)); } $out .= '</p> </div> <footer class="entry-meta"> <a href="' . get_permalink($post['ID']) . '" class="btn btn-transparent btn-lets-talk"><span>' . __('Read article', 'tfuse') . ' <i class="icon-chevron-right align-right-icon"></i></span></a> </footer> </div> </div> </div>'; } } return $out; }