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 = '

'.$Heading.'

'; foreach ($ifYouLikedThats as $ifYouLikedThat) { $postSentence = ''; if (substr(strtolower($showSentence),0,1) == 'y') { $pieces = split("\. ?", $ifYouLikedThat->post_content); if (strlen($pieces[0]) > 0) { $postSentence = '
'.strip_tags($pieces[0]).'.'; } } $ifYouLikedThatsHTML .= '

'.$ifYouLikedThat->post_title.' by '.$ifYouLikedThat->display_name.' on '.date('F jS, Y',strtotime($ifYouLikedThat->post_date)).$postSentence.'

'; } $ifYouLikedThatsHTML .= '
'; } else { $ifYouLikedThatsHTML = ''; } return $content.=$ifYouLikedThatsHTML; } // execute main function on execution of the_content add_action('the_content', 'if_you_liked_that'); function if_you_liked_that_css() { echo " "; } //poke the css into the add_action('wp_head', 'if_you_liked_that_css'); function plugin_menu() { $message = null; $message_updated = __("If You Liked That Options Updated."); // update options if ($_POST['action'] && $_POST['action'] == 'iylt_update') { $message = $message_updated; update_option('ifyoulikedthat_numberOfPosts', $_POST['ifyoulikedthat_numberOfPosts']); update_option('ifyoulikedthat_orderBy', $_POST['ifyoulikedthat_orderBy']); update_option('ifyoulikedthat_showSentence', $_POST['ifyoulikedthat_showSentence']); update_option('ifyoulikedthat_showHeading', $_POST['ifyoulikedthat_showHeading']); update_option('ifyoulikedthat_excludeCategories', $_POST['ifyoulikedthat_excludeCategories']); update_option('ifyoulikedthat_singleOnly', $_POST['ifyoulikedthat_singleOnly']); wp_cache_flush(); } if ($message) : ?>

Visit Bochgoch.') ?>

> Random
> Date of post - ascending
> Date of post - descending
> Title of post - ascending
> Title of post - descending
(Y/N)
(Y/N)