$numOfPosts, 'offset' => $offset, 'post_status' => 'publish' )); } // Get post by slug ("post_name" in wp db) function getPost($slug = FALSE) { if(!$slug) return FALSE; $getPost = get_page_by_path($slug, 'ARRAY_A', 'post'); if($getPost) { if($getPost['post_status'] == "publish") return $getPost; else return false; } else { return false; } } // Get preview to a post function getPreview($id = FALSE) { if(!$id) return FALSE; return get_post($id, 'ARRAY_A'); } // Get related posts based on tags used in original post function getRelated($postID, $numResults = 3) { $related = array(); $tags = array(); $getTags = wp_get_post_tags($postID); if($getTags && $postID) { foreach($getTags as $tag) { $tags[] = $tag->name; } $getRelated = get_posts(array( 'numberposts' => $numResults, 'tag_slug__in' => $tags, 'post__not_in' => array($postID) )); foreach($getRelated as $relatedPost) { $related[] = array( 'ID' => $relatedPost->ID, 'image' => $this->getFeaturedImageUrl($relatedPost->ID), 'post_title' => $relatedPost->post_title, 'post_name' => $relatedPost->post_name ); } } return $related; } function getFeaturedImageUrl($postID, $size = "large") { $image = DEFAULT_BLOG_IMAGE_URL; $getImage = wp_get_attachment_image_src(get_post_thumbnail_id($postID), $size); if($getImage) $image = $getImage[0]; return $image; } function search($term) { return get_posts(array('s' => $term, 'numberposts' => -1)); } function cleanOut($content) { return tag_escape($content); } } $blog = new Blog();