/** * Constructor */ public function __construct() { $this->_recent_posts = PF_Recent_Posts_init(); $this->_featured_posts = PF_Featured_Posts_init(); $this->_popular_posts = PF_Popular_Posts_init(); $this->_related_posts = PF_Related_Posts_init(); add_shortcode(self::RECENT_POSTS_SC, array(&$this, 'process_recent_posts_sc')); add_shortcode(self::POPULAR_POSTS_SC, array(&$this, 'process_popular_posts_sc')); add_shortcode(self::FEATURED_POSTS_SC, array(&$this, 'process_featured_posts_sc')); add_shortcode(self::RELATED_POSTS_SC, array(&$this, 'process_related_posts_sc')); }
} return apply_filters('pf_related_posts_result', $q, $args); } } public function search_by_tag($args, $post_id) { $tags = wp_get_post_tags($post_id); $tagIDs = array(); if ($tags) { $tagcount = count($tags); for ($i = 0; $i < $tagcount; $i++) { $tagIDs[$i] = $tags[$i]->term_id; } $args['tag__in'] = $tagIDs; } return apply_filters('pf_related_posts_result', new WP_Query($args), $args); } public function search_by_category($args) { $cat = get_the_category(); $category = $cat[0]->cat_ID; $args['cat'] = $category; return apply_filters('pf_related_posts_result', new WP_Query($args), $args); } } function PF_Related_Posts_init() { return PF_Related_Posts::get_instance(); } $pf_related_posts = PF_Related_Posts_init(); }