function tfuse_members($atts, $content = null) { extract(shortcode_atts(array('post' => ''), $atts)); $output = ''; $post = explode(',', $post); $query = new WP_Query(array('posts_per_page' => -1, 'post_type' => 'member', 'post__in' => $post)); $posts = $query->get_posts(); if (!empty($posts)) { $output .= '<div class="our-team">'; foreach ($posts as $post) { $job = tfuse_page_options('job', '', $post->ID); $image = wp_get_attachment_url(get_post_thumbnail_id($post->ID, 'post-thumbnails')); if (!empty($image)) { $image = TF_GET_IMAGE::get_src_link($image, 270, 270); } $output .= '<div class="col-lg-3 col-md-3 col-sm-6 col-xs-6"> <div class="image-our-team"> <img src="' . $image . '" alt="' . $post->post_title . '"> </div> <h3>' . $post->post_title . '</h3> <span class="function">' . $job . '</span> </div>'; } $output .= '</div>'; } return $output; }
/** * Minigallery * * To override this shortcode in a child theme, copy this file to your child theme's * theme_config/extensions/shortcodes/shortcodes/ folder. * * Optional arguments: * id: post/page id * order: ASC, DESC * orderby: * include: * exclude: * pretty: true/false use or not prettyPhoto * icon_plus: * class: css class e.g. boxed * carousel: jCarousel Configuration. http://sorgalla.com/projects/jcarousel/ */ function tfuse_minigallery($attr, $content = null) { global $post; if (isset($attr['orderby'])) { $attr['orderby'] = sanitize_sql_orderby($attr['orderby']); if (!$attr['orderby']) { unset($attr['orderby']); } } extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => isset($post->ID) ? $post->ID : $attr['id'], 'include' => '', 'exclude' => '', 'pretty' => true, 'icon_plus' => '<span></span>', 'carousel' => 'easing: "easeInOutQuint",animation: 600', 'class' => 'boxed'), $attr)); if (!empty($include)) { $include = preg_replace('/[^0-9,]+/', '', $include); $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); $attachments = array(); foreach ($_attachments as $key => $val) { $attachments[$val->ID] = $_attachments[$key]; } } elseif (!empty($exclude)) { $exclude = preg_replace('/[^0-9,]+/', '', $exclude); $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); } else { $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); } if (empty($attachments)) { return ''; } $uniq = rand(1, 200); $out = ' <script type="text/javascript"> jQuery(document).ready(function($) { $("#mycarousel' . $uniq . '").jcarousel({ ' . $carousel . ' }); }); </script> '; $out .= ' <div class="minigallery-list minigallery ' . $class . '"> <ul id="mycarousel' . $uniq . '" class="jcarousel-skin-tango">'; if ($icon_plus) { $out .= '<span></span>'; } foreach ($attachments as $id => $attachment) { if ($pretty) { $out .= '<li><a href="' . $attachment->guid . '" rel="prettyPhoto[gallery' . $uniq . ']">' . '<img src="' . TF_GET_IMAGE::get_src_link($attachment->guid, 102, 102) . '" alt=' . $attachment->post_title . '>' . $icon_plus . '</a></li>'; } else { $out .= '<li>' . '<img src="' . TF_GET_IMAGE::get_src_link($attachment->guid, 102, 102) . '" alt=' . $attachment->post_title . '>' . '</li>'; } } $out .= ' </ul> </div> <div class="clear"></div> '; return $out; }
/** * Minigallery * * To override this shortcode in a child theme, copy this file to your child theme's * theme_config/extensions/shortcodes/shortcodes/ folder. * * Optional arguments: * id: post/page id * order: ASC, DESC * orderby: * include: * exclude: * pretty: true/false use or not prettyPhoto * icon_plus: * class: css class e.g. boxed * carousel: jCarousel Configuration. http://sorgalla.com/projects/jcarousel/ */ function tfuse_minigallery($attr, $content = null) { extract(shortcode_atts(array('title' => '', 'id' => ''), $attr)); global $post; extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => isset($post->ID) ? $post->ID : $attr['id'], 'include' => '', 'exclude' => '', 'pretty' => true, 'carousel' => 'easing: "easeInOutQuint",animation: 600', 'class' => 'boxed', 'prettyphoto' => ''), $attr)); $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); if (empty($attachments)) { return ''; } $uniq = rand(1, 200); $out = '<h3 class="shortcode_title">' . $title . '</h3> <div class="minigallery_carousel"> <div class="carousel_content"> <ul id="minigallery' . $uniq . '">'; foreach ($attachments as $id => $attachment) { $link = wp_get_attachment_image_src($id, 'full', true); $image_link_attach = $link[0]; $imgsrc = wp_get_attachment_image_src($id, array(100, 100), false); $image_src = $imgsrc[0]; $img = TF_GET_IMAGE::get_src_link($image_src, 132, 100); if ($prettyphoto == 'true') { $out .= '<li><a href="' . $image_link_attach . '" data-rel="prettyPhoto[mg' . $uniq . ']" class="zoom" rel="prettyPhoto[mg' . $uniq . ']"><img src="' . $img . '" /></a></li>'; } else { $out .= '<li><img src="' . $img . '" /></li>'; } } $out .= '</ul> </div> <a class="prev" id="minigallery' . $uniq . '_prev" href="#"><span class="tficon-chevron-left"></span></a> <a class="next" id="minigallery' . $uniq . '_next" href="#"><span class="tficon-chevron-right"></span></a> </div>'; $out .= ' <script> jQuery(document).ready(function($) { $("#minigallery' . $uniq . '").carouFredSel({ next : "#minigallery' . $uniq . '_next", prev : "#minigallery' . $uniq . '_prev", auto: false, circular: false, infinite: true, width: "100%", scroll: { items : 1 } }); }); </script>'; return $out; }
function tfuse_text_info($atts, $content = null) { extract(shortcode_atts(array('link' => '', 'img' => '', 'color' => '', 'title' => '', 'link_title' => ''), $atts)); $out = '<div class="block-item"> <div class="block-image"> <img src="' . TF_GET_IMAGE::get_src_link($img, 300, 280) . '" alt=""/> <div class="block-caption"><h2 style="color:' . $color . '">' . $title . '</h2></div> </div> <div class="block-aside"> ' . do_shortcode($content) . ' </div> <div class="block-meta"> <a href="' . $link . '">' . $link_title . '</a> </div> </div>'; return $out; }
echo $image; ?> " class="see-more-gallery" data-rel="prettyPhoto[<?php echo $post->ID; ?> ]" title="<?php echo get_the_title(); ?> "> <span><?php _e('More', 'tfuse'); ?> </span> </a> <img src="<?php echo TF_GET_IMAGE::get_src_link($image, 270, 270); ?> " alt=""> </div> <?php if (!empty($gallery)) { ?> <div class="gallery-array"> <?php foreach ($gallery as $img) { ?> <a href="<?php echo $img['url']; ?> " data-rel="prettyPhoto[<?php echo $post->ID;
} ?> <?php if (!empty($gallery)) { ?> <?php foreach ($gallery as $img) { ?> <a href="<?php echo TF_GET_IMAGE::get_src_link($img['url'], 715, 498); ?> " title="<?php echo get_the_title(); ?> "><img src="<?php echo TF_GET_IMAGE::get_src_link($img['url'], 715, 498); ?> " alt="<?php echo get_the_title(); ?> "></a> <?php } ?> <?php } ?> </div> </div> <div class="entry-content">
function tfuse_filter_get_avatar($avatar, $id_or_email, $size, $default, $alt) { $avatar_src = tfuse_options('default_avatar', false); if (empty($avatar_src)) { return $avatar; } $email = ''; if (is_numeric($id_or_email)) { $id = (int) $id_or_email; $user = get_userdata($id); if ($user) { $email = $user->user_email; } } elseif (is_object($id_or_email)) { // No avatar for pingbacks or trackbacks $allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment')); if (!empty($id_or_email->comment_type) && !in_array($id_or_email->comment_type, (array) $allowed_comment_types)) { return false; } if (!empty($id_or_email->user_id)) { $id = (int) $id_or_email->user_id; $user = get_userdata($id); if ($user) { $email = $user->user_email; } } elseif (!empty($id_or_email->comment_author_email)) { $email = $id_or_email->comment_author_email; } } else { $email = $id_or_email; } if (!tfuse_user_has_gravatar($email)) { $avatar = "<img alt='' src='" . TF_GET_IMAGE::get_src_link($avatar_src, $size, $size) . "' class='avatar avatar-" . $size . " photo avatar-default' height='" . $size . "' width='" . $size . "' />"; } return $avatar; }
function tfuse_projects($atts, $content = null) { extract(shortcode_atts(array('post' => ''), $atts)); $output = ''; $uniq = rand(1, 100); $post = explode(',', $post); $query = new WP_Query(array('posts_per_page' => -1, 'post_type' => 'project', 'orderby' => 'post__in', 'post__in' => $post)); $posts = $query->get_posts(); if (!empty($posts)) { $output .= '<div class="recent-slider"> <ul id="recent-slider' . $uniq . '">'; foreach ($posts as $post) { $image = wp_get_attachment_url(get_post_thumbnail_id($post->ID, 'post-thumbnails')); if (!empty($image)) { $image = TF_GET_IMAGE::get_src_link($image, 285, 326); } $current_post = get_post($post->ID); $output .= '<li data-recentslider1="1"> <div class="recent-slider-text"> <h3 class="title"><a href="' . get_permalink($post->ID) . '">' . $post->post_title . '</a></h3> <div class="line-title-sldier"></div> <div class="recent-slider-description">'; if (tfuse_options('post_content') == 'content') { $output .= $current_post->post_content; } else { $output .= !empty($current_post->post_excerpt) ? $current_post->post_excerpt : strip_tags(tfuse_shorten_string(apply_filters('the_content', $current_post->post_content), 150)); } $output .= '</div> </div> <div class="recent-slider-image"> <a href="' . get_permalink($post->ID) . '" class="recent-slider-thumbnail"><span>' . __('More', 'tfuse') . '</span></a> <img src="' . $image . '" > </div> </li>'; } $output .= '</ul> <div id="recent-slider' . $uniq . '-controls" class="recent-slider-controls"></div> <a id="recent-slider' . $uniq . '-prev" class="prev" href="#">prev</a> <a id="recent-slider' . $uniq . '-next" class="next" href="#">next</a> </div>'; $output .= ' <script> jQuery(document).ready(function(){ function recentsliderInit() { jQuery("#recent-slider' . $uniq . '").carouFredSel({ swipe : { onTouch: true }, next : "#recent-slider' . $uniq . '-next", prev : "#recent-slider' . $uniq . '-prev", pagination : "#recent-slider' . $uniq . '-controls", infinite: false, items: 1, auto: { play: false, timeoutDuration: 0 }, scroll: { items : 1, fx: "crossfade", easing: "linear", pauseOnHover: true, duration: 300 } }); } recentsliderInit(); jQuery(window).resize(function() { recentsliderInit(); }); var tControlsHeight = jQuery(".recent-slider-controls").innerHeight(); jQuery(".recent-slider-controls").css("margin-top" , -tControlsHeight/2); //Script align center the text for two mini slider var caroufredsel_wrapper = jQuery(".caroufredsel_wrapper"); var recent_slider_text = jQuery(".recent-slider-text"); caroufredsel_wrapper.each(function(){ hei1 = jQuery(this).height(); recent_slider_text.each(function(){ hei2 = jQuery(this).height(); jQuery(this).css({ "padding-top" :hei1/2-hei2/2 }); }); }); }); </script> '; } return $output; }
/** * The template for displaying posts on archive pages. * To override this template in a child theme, copy this file * to your child theme's folder. * * @since Philanthropy 1.0 */ global $more, $post; $more = apply_filters('tfuse_more_tag', 0); $image = wp_get_attachment_url(get_post_thumbnail_id($post->ID, 'post-thumbnails')); $art_type = tfuse_page_options('article_type'); if (!empty($image)) { if ($art_type == 'post-style-4' || $art_type == 'post-style-3') { $image = TF_GET_IMAGE::get_src_link($image, 270, 380); } elseif ($art_type == 'post-style-1' || $art_type == 'post-style-2') { $image = TF_GET_IMAGE::get_src_link($image, 269, 267); } } ?> <article class="post <?php echo $art_type; ?> "> <div class="entry-aside"> <header class="entry-header"> <?php if ($art_type != 'post-style-7') { ?> <?php if (!empty($image)) {
} else { '<p>' . the_excerpt() . '</p>'; } ?> </div> </div> <div class="post-thumbnail"> <?php if (!empty($image)) { ?> <a href="<?php the_permalink(); ?> " class="post-thumbnail-image"><span><?php _e('More', 'tfuse'); ?> </span></a> <img src="<?php echo TF_GET_IMAGE::get_src_link($image, 285, 326); ?> " alt="<?php echo get_the_title(); ?> "> <?php } ?> </div> </div> </div> </div>
function tfuse_ajax_get_posts() { $post_type = $_POST['post_type']; $search_param = $_POST['search_param']; $max = intval($_POST['max']); $pageNum = intval($_POST['pageNum']); $search_key = $_POST['search_key']; $allhome = $_POST['allhome']; $allblog = $_POST['allblog']; $homepage = $_POST['homepage']; $cat_ids = $_POST['cat_ids']; $cat_ID = intval($_POST['id']); $is_tax = $_POST['is_tax']; $items = get_option('posts_per_page'); $pos4 = $pos1 = $pos2 = $pos3 = $pos5 = $pos6 = $pos7 = $pos8 = $pos9 = $allpos = $pos = $pos10 = $pos11 = $pos12 = $pos13 = $pos14 = $pos15 = $pos16 = $pos17 = ''; $posts = array(); if ($pageNum <= $max) { if ($homepage == 'homepage' && $allhome == 'nonehomeall') { $specific = tfuse_options('categories_select_categ'); if (is_user_logged_in()) { $args = array('post_status' => array('publish', 'private'), 'paged' => $pageNum, 'cat' => $specific); } else { $args = array('post_status' => array('publish'), 'paged' => $pageNum, 'cat' => $specific); } $query = new WP_Query($args); $posts = $query->posts; } elseif ($homepage == 'blogpage' && $allblog == 'allblogcategories') { if (is_user_logged_in()) { $args = array('post_status' => array('publish', 'private'), 'paged' => $pageNum, 'post_type' => 'post'); } else { $args = array('post_status' => array('publish'), 'paged' => $pageNum, 'post_type' => 'post'); } $query = new WP_Query($args); $posts = $query->posts; } elseif ($homepage == 'blogpage' && $allblog == 'noneblogall') { $specific = tfuse_options('categories_select_categ_blog'); $args = array('paged' => $pageNum, 'cat' => $specific); $query = new WP_Query($args); $posts = $query->posts; } elseif ($homepage == 'homepage' && $allhome == 'allhomecategories') { if (is_user_logged_in()) { $args = array('post_status' => array('publish', 'private'), 'paged' => $pageNum, 'post_type' => 'post'); } else { $args = array('post_status' => array('publish'), 'paged' => $pageNum, 'cat' => $cat_ids); } $query = new WP_Query($args); $posts = $query->posts; } elseif ($is_tax == 'category') { if (is_user_logged_in()) { $query = new WP_Query(array('post_status' => array('publish', 'private'), 'cat' => $cat_ID, 'paged' => $pageNum)); } else { $query = new WP_Query(array('post_status' => array('publish'), 'cat' => $cat_ID, 'paged' => $pageNum)); } $posts = $query->posts; } elseif ($is_tax == 'galleries') { if (is_user_logged_in()) { $args = array('post_status' => array('publish', 'private'), 'paged' => $pageNum, 'tax_query' => array(array('taxonomy' => 'galleries', 'field' => 'id', 'terms' => $cat_ID))); } else { $args = array('post_status' => array('publish'), 'paged' => $pageNum, 'tax_query' => array(array('taxonomy' => 'galleries', 'field' => 'id', 'terms' => $cat_ID))); } $query = new WP_Query($args); $posts = $query->posts; } elseif ($is_tax == 'projects') { if (is_user_logged_in()) { $args = array('post_status' => array('publish', 'private'), 'paged' => $pageNum, 'tax_query' => array(array('taxonomy' => 'projects', 'field' => 'id', 'terms' => $cat_ID))); } else { $args = array('post_status' => array('publish'), 'paged' => $pageNum, 'tax_query' => array(array('taxonomy' => 'projects', 'field' => 'id', 'terms' => $cat_ID))); } $query = new WP_Query($args); $posts = $query->posts; } elseif ($is_tax == 'search') { $query = new WP_Query(array('post_status' => array('publish'), 's' => $search_key, 'paged' => $pageNum)); $posts = $query->posts; } $cnt = 0; foreach ($posts as $post) { $cnt++; //get date format $d = get_option('date_format'); //get comments number $num_comments = get_comments_number($post->ID); if ($num_comments == 0) { $comments = __('No Comments', 'tfuse'); } elseif ($num_comments > 1) { $comments = $num_comments . __(' Comments', 'tfuse'); } else { $comments = __('1 Comment', 'tfuse'); } if ($is_tax == 'galleries') { $image = wp_get_attachment_url(get_post_thumbnail_id($post->ID, 'post-thumbnails')); $gallery = tfuse_page_options('gallery', '', $post->ID); $pos1 .= '<li class="gallery-item">'; if (!empty($image)) { $pos2 .= '<div class="gallery-img"> <a href="' . $image . '" class="see-more-gallery" data-rel="prettyPhoto[' . $post->ID . ']" title="' . $post->post_title . '"> <span>' . __('More', 'tfuse') . '</span> </a> <img src="' . TF_GET_IMAGE::get_src_link($image, 270, 270) . '" alt=""> </div>'; if (!empty($gallery)) { $pos3 .= '<div class="gallery-array">'; foreach ($gallery as $img) { $pos4 .= '<a href="' . $img['url'] . '" data-rel="prettyPhoto[' . $post->ID . ']" title="' . $img['title'] . '"> </a>'; } $pos5 .= '</div>'; } } $pos5 .= '<span class="title"><a href="' . get_permalink($post->ID) . '">' . $post->post_title . '</a></span> </li>'; $pos = $pos1 . $pos2 . $pos3 . $pos4 . $pos5; $pos1 = $pos2 = $pos3 = $pos4 = $pos5 = ''; } elseif ($is_tax == 'projects') { $image = wp_get_attachment_url(get_post_thumbnail_id($post->ID, 'post-thumbnails')); $pos5 .= '<div class="col-md-6 col-sm-6 col-xs-12 clearfix"> <div class="post"> <div class="inner"> <div class="entry-aside"> <header class="entry-header"> <h1 class="entry-title"><a href="' . get_permalink($post->ID) . '">' . $post->post_title . '</a> </h1> </header> <div class="divider"></div> <div class="entry-content">'; $pos6 .= !empty($post->post_excerpt) ? '<p>' . $post->post_excerpt . '</p>' : '<p>' . strip_tags(tfuse_shorten_string(apply_filters('the_content', $post->post_content), 50)) . '</p>'; $pos7 .= '</div> </div> <div class="post-thumbnail">'; if (!empty($image)) { $pos8 .= '<a href="' . get_permalink($post->ID) . '" class="post-thumbnail-image"><span>' . __('More', 'tfuse') . '</span></a> <img src="' . $image . '" alt="' . $post->post_title . '">'; } $pos9 .= '</div> </div> </div> </div>'; $pos = $pos5 . $pos6 . $pos7 . $pos8 . $pos9; $pos5 = $pos6 = $pos7 = $pos8 = $pos9 = ''; } elseif ($is_tax == 'category') { $image = wp_get_attachment_url(get_post_thumbnail_id($post->ID, 'post-thumbnails')); $art_type = tfuse_page_options('article_type', '', $post->ID); if (!empty($image)) { if ($art_type == 'post-style-4' || $art_type == 'post-style-3') { $image = TF_GET_IMAGE::get_src_link($image, 270, 380); } elseif ($art_type == 'post-style-1' || $art_type == 'post-style-2') { $image = TF_GET_IMAGE::get_src_link($image, 269, 267); } } $user_data = get_user_by('id', $post->post_author); $pos11 .= '<article class="post ' . $art_type . '"> <div class="entry-aside"> <header class="entry-header">'; if ($art_type != 'post-style-7') { if (!empty($image)) { $pos12 .= '<div class="post-thumbnail"> <a href="' . get_permalink($post->ID) . '" class="post-thumbnail-image"> <span>' . __('More', 'tfuse') . '</span> </a> <img src="' . $image . '" alt=""> </div>'; } } $pos13 .= '<div class="entry-meta"> <time class="entry-date" datetime="">' . get_the_time($d, $post->ID) . '</time> <span class="author"> ' . __('by ', 'tfuse') . '<a href="' . get_author_posts_url($post->post_author, $user_data->data->user_nicename) . '">' . $user_data->data->user_nicename . '</a></span> <span class="cat-links"> ' . __('in', 'tfuse') . ' ' . tfuse_cat_links($post->post_type, $post->ID) . '</span> <h2 class="entry-title"><a href="' . get_permalink($post->ID) . '">' . $post->post_title . '</a></h2>'; if ($art_type == 'post-style-7') { if (!empty($image)) { $pos14 .= '<div class="post-thumbnail"> <a href="' . get_permalink($post->ID) . '" class="post-thumbnail-image"> <span>' . __('More', 'tfuse') . '</span> </a> <img src="' . $image . '" alt=""> </div>'; } } $pos15 .= '</div> </header> <div class="entry-content">'; $pos16 .= !empty($post->post_excerpt) ? '<p>' . $post->post_excerpt . '</p>' : '<p>' . strip_tags(tfuse_shorten_string(apply_filters('the_content', $post->post_content), 50)) . '</p>'; $pos17 .= '</div> <footer class="entry-meta clearfix"> <a href="' . get_permalink($post->ID) . '" class="btn btn-yellow btn-read-more"><span>' . __('Read More', 'tfuse') . '</span></a> <a href="' . get_permalink($post->ID) . '#comments" class="btn btn-transparent link-comment"><span>' . $comments . '</span></a> </footer> </div> </article>'; $pos = $pos11 . $pos12 . $pos13 . $pos14 . $pos15 . $pos16 . $pos17; $pos11 = $pos12 = $pos13 = $pos14 = $pos15 = $pos16 = $pos17 = ''; } elseif ($is_tax == 'search') { $img = tfuse_page_options('thumbnail_image', null, $post->ID); if (tfuse_options('disable_listing_lightbox')) { $image = '<a href="' . $img . '" rel="prettyPhoto[gallery' . $post->ID . ']"> <img src="' . $img . '" height="200" width="220" alt=""> </a>'; } else { $image = '<a href="' . get_permalink($post->ID) . '"><img src="' . $img . '" height="200" width="220" alt="" ></a>'; } $pos1 .= '<div class="post-item clearfix"> <div class="post-image">' . $image . '</div> <div class="post-meta">'; if (tfuse_options('date_time')) { $pos2 .= '<span class="post-date">' . get_the_time($d, $post->ID) . '</span> | '; } $pos3 .= '<a href="' . get_comments_link($post->ID) . '" class="link-comments">' . $comments . '</a> </div> <div class="post-title"> <h3><a href="' . get_permalink($post->ID) . '">' . $post->post_title . '</a></h3> </div> <div class="post-descr entry"> <p>' . strip_tags(tfuse_shorten_string(apply_filters('the_content', $post->post_content), 30)) . '</p> </div> <div class="post-more"><a href="' . get_permalink($post->ID) . '">' . __('READ THE ARTICLE', 'tfuse') . '</a></div> </div>'; $pos = $pos1 . $pos2 . $pos3; $pos1 = $pos2 = $pos3 = ''; } $allpos[] = $pos; } $rsp = array('html' => $allpos, 'items' => $items, 'posts' => $posts); echo json_encode($rsp); } die; }
function tfuse_show_similar_posts($id, $post_type) { if ($post_type == 'story') { $tags = wp_get_post_terms($id, 'tags'); } elseif ($post_type == 'service') { $tags = wp_get_post_terms($id, 'tags_service'); } elseif ($post_type == 'advice') { $tags = wp_get_post_terms($id, 'tags_advice'); } elseif ($post_type == 'exercise') { $tags = wp_get_post_terms($id, 'tags_exercises'); } else { $tags = wp_get_post_tags($id); } if (!empty($tags)) { $tags_ids = array(); foreach ($tags as $tag) { $tags_ids[] = $tag->term_id; } if ($post_type == 'story') { $query = new WP_Query(array('post_type' => 'story', 'posts_per_page' => 2, 'post__not_in' => array($id), 'tax_query' => array(array('taxonomy' => 'tags', 'field' => 'id', 'terms' => $tags_ids)))); } elseif ($post_type == 'service') { $query = new WP_Query(array('post_type' => 'service', 'posts_per_page' => 2, 'post__not_in' => array($id), 'tax_query' => array(array('taxonomy' => 'tags_service', 'field' => 'id', 'terms' => $tags_ids)))); } else { $query = new WP_Query(array('post_type' => 'post', 'tag__in' => $tags_ids, 'posts_per_page' => 2, 'post__not_in' => array($id))); } if (!empty($query->posts)) { ?> <section class="post-similar clearfix"> <h6 class="title"><?php _e('You may also like these posts', 'tfuse'); ?> </h6> <?php foreach ($query->posts as $item) { $image = wp_get_attachment_url(get_post_thumbnail_id($item->ID, 'post-thumbnails')); if (!empty($image)) { echo '<a href="' . get_permalink($item->ID) . '"><img src="' . TF_GET_IMAGE::get_src_link($image, 322, 234) . '" /><span>' . strip_tags($item->post_title) . '</span></a>'; } } ?> </section> <?php } } }