cat_ID; } // now stick them together into a string for our sql query: 'cat1', 'cat2', 'cat3', ... $cats_string = "'" . implode("', '", $the_cats) . "'"; $numPosts = get_option('ifyoulikedthat_numberOfPosts'); $orderBy = get_option('ifyoulikedthat_orderBy'); $showSentence = get_option('ifyoulikedthat_showSentence'); $Heading = get_option('ifyoulikedthat_showHeading'); $excludeCategories = get_option('ifyoulikedthat_excludeCategories'); if (strlen($excludeCategories) == 0) {$excludeCategories = '-9999';} $singleOnly = get_option('ifyoulikedthat_singleOnly'); if ($post->post_type == 'page') {return $content;} // exclude on pages if (!is_single() and $singleOnly == 'Y') {return $content;} // include only on single view $ifYouLikedThats = $wpdb->get_results("SELECT t1.ID, t1.post_title, t1.post_date, t1.post_content, t3.display_name FROM $wpdb->posts t1, $wpdb->post2cat t2, $wpdb->users t3 WHERE t1.ID=t2.post_id AND t1.post_status = 'publish' AND t1.ID != ".$post->ID." AND t2.category_id IN (".$cats_string.") AND t2.category_id NOT IN (".$excludeCategories.") AND t1.post_author = t3.ID ORDER BY ".$orderBy." LIMIT ".$numPosts); if (count($ifYouLikedThats) > 0) { $ifYouLikedThatsHTML = '
'.$ifYouLikedThat->post_title.' by '.$ifYouLikedThat->display_name.' on '.date('F jS, Y',strtotime($ifYouLikedThat->post_date)).$postSentence.'
'; } $ifYouLikedThatsHTML .= 'Visit Bochgoch.') ?>