related post
-
Hello guys, i have one problem and i want your help.
I have that code://------------------------------------------------------ // Related Posts //------------------------------------------------------ if(!function_exists('cherry_related_posts')){ function cherry_related_posts($args = array()){ global $post; $default = array( 'post_type' => get_post_type($post), 'class' => 'related-posts', 'class_list' => 'related-posts_list', 'class_list_item' => 'related-posts_item', 'display_title' => true, 'display_link' => true, 'display_thumbnail' => true, 'width_thumbnail' => 170, 'height_thumbnail' => 170, 'before_title' => '<h3 class="related-posts_h">', 'after_title' => '</h3>', 'posts_count' => 4 ); extract(array_merge($default, $args)); $post_tags = wp_get_post_terms($post->ID, $post_type.'_tag', array("fields" => "slugs")); $tags_type = $post_type=='post' ? 'tag' : $post_type.'_tag' ; $suppress_filters = get_option('suppress_filters');// WPML filter $blog_related = apply_filters( 'cherry_text_translate', of_get_option('blog_related'), 'blog_related' ); if ($post_tags && !is_wp_error($post_tags)) { $args = array( "$tags_type" => implode(',', $post_tags), 'post_status' => 'publish', 'posts_per_page' => $posts_count, 'ignore_sticky_posts' => 1, 'post__not_in' => array($post->ID), 'post_type' => $post_type, 'suppress_filters' => $suppress_filters ); query_posts($args); if ( have_posts() ) { $output = '<div class="'.$class.'">'; $output .= $display_title ? $before_title.$blog_related.$after_title : '' ; $output .= '<ul class="'.$class_list.' clearfix">'; while( have_posts() ) { the_post(); $thumb = has_post_thumbnail() ? get_post_thumbnail_id() : PARENT_URL.'/images/empty_thumb.gif'; $blank_img = stripos($thumb, 'empty_thumb.gif'); $img_url = $blank_img ? $thumb : wp_get_attachment_url( $thumb,'full'); $image = $blank_img ? $thumb : aq_resize($img_url, $width_thumbnail, $height_thumbnail, true) or $img_url; $output .= '<li class="'.$class_list_item.'">'; $output .= $display_thumbnail ? '<figure class="thumbnail featured-thumbnail"><a href="'.get_permalink().'" title="'.get_the_title().'"><img data-src="'.$image.'" alt="'.get_the_title().'" /></a></figure>': '' ; $output .= $display_link ? '<a href="'.get_permalink().'" >'.get_the_title().'</a>': '' ; $output .= '</li>'; } $output .= '</ul></div>'; echo $output; } wp_reset_query(); } } }
That code is for related post in my blog, but works with TAGS, i want to change that and i make it to works with CATEGORIES, can you help me please? thank you!
- The topic ‘related post’ is closed to new replies.