Arkadaşlar dagon designın
her kategorinin son yazısının başlığını gösteren eklentisini kullanıyorum fakat bunu her kategorinin son 5 yazısının başlığını gösteren hale getirmek istiyorum, yardımcı olurmusunuz?

eklentinin anasayfası

kodları

<?php
/*
Plugin Name: Latest From Each Category
Plugin URI: http://www.dagondesign.com/articles/latest-post-from-each-category-plugin-for-wordpress/
Description: Displays a list of the latest post in each category.
Author: Dagon Design
Version: 1.7
Author URI: http://www.dagondesign.com
*/

$ddle_version = '1.7';

// Setup defaults if options do not exist
add_option('ddle_header', '<h2>Latest Post From Each Category</h2>');
add_option('ddle_sort', 'cata');
add_option('ddle_cat_links', TRUE);
add_option('ddle_hide_protected', TRUE);
add_option('ddle_show_date', TRUE);
add_option('ddle_date_format', 'F jS, Y');
add_option('ddle_excerpts', FALSE);
add_option('ddle_chars', 200);
add_option('ddle_comment_link', FALSE);
add_option('ddle_comment_num', FALSE);
add_option('ddle_comments_none', FALSE);
add_option('ddle_limit', 0);



function ddle_add_option_pages() {
	if (function_exists('add_options_page')) {
		add_options_page('Latest From Each Category', 'DDLatestFromEach', 8, __FILE__, 'ddle_options_page');
	}		
}



function ddle_options_page() {

	global $ddle_version;

	if (isset($_POST['set_defaults'])) {
		echo '<div id="message" class="updated fade"><p><strong>';

		update_option('ddle_header', '<h2>Latest Post From Each Category</h2>');
		update_option('ddle_sort', 'cata');
		update_option('ddle_cat_links', TRUE);
		update_option('ddle_hide_protected', TRUE);
		update_option('ddle_show_date', TRUE);
		update_option('ddle_date_format', 'F jS, Y');
		update_option('ddle_excerpts', FALSE);
		update_option('ddle_chars', 200);
		update_option('ddle_comment_link', FALSE);
		update_option('ddle_comment_num', FALSE);
		update_option('ddle_comments_none', FALSE);
		update_option('ddle_limit', 0);
			
		echo 'Default Options Loaded!';
		echo '</strong></p></div>';

	} else if (isset($_POST['info_update'])) {

		update_option('ddle_header', (string) $_POST["ddle_header"]);
		update_option('ddle_sort', (string) $_POST["ddle_sort"]);
		update_option('ddle_cat_links', (string) $_POST["ddle_cat_links"]);
		update_option('ddle_hide_protected', (bool)$_POST["ddle_hide_protected"]);
		update_option('ddle_show_date', (bool) $_POST["ddle_show_date"]);
		update_option('ddle_date_format', (string) $_POST["ddle_date_format"]);
		update_option('ddle_excerpts', (bool) $_POST["ddle_excerpts"]);
		update_option('ddle_chars', (string) $_POST["ddle_chars"]);
		update_option('ddle_comment_link', (bool) $_POST["ddle_comment_link"]);
		update_option('ddle_comment_num', (bool) $_POST["ddle_comment_num"]);
		update_option('ddle_comments_none', (bool) $_POST["ddle_comments_none"]);
		update_option('ddle_limit', (string) $_POST["ddle_limit"]);
		
		echo 'Configuration Updated!';
		echo '</strong></p></div>';

	} ?>

	<div class=wrap>

	<h2>Latest Posts From Each Category v<?php echo $ddle_version; ?></h2>

	<p>For information and updates, please visit:<br />
	<a href="http://www.dagondesign.com/articles/latest-post-from-each-category-plugin-for-wordpress/">http://www.dagondesign.com/articles/latest-post-from-each-category-plugin-for-wordpress/</a></p>


	<form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>">
	<input type="hidden" name="info_update" id="info_update" value="true" />


	<fieldset class="options"> 
	<legend>Options</legend>
	<table width="100%" border="0" cellspacing="0" cellpadding="6">

	<tr valign="top"><td width="35%" align="right">
		Header text
	</td><td align="left">
		<input name="ddle_header" type="text" size="50" value="<?php echo get_option('ddle_header') ?>"/>
	</td></tr>

	<tr valign="top"><td width="35%" align="right">
		Sort order
	</td><td align="left">
		<input name="ddle_sort" type="radio" value="cata" <?php if (get_option('ddle_sort') == "cata") echo "checked='checked'"; ?> />&nbsp;&nbsp; By category (ascending)<br />
		<input name="ddle_sort" type="radio" value="catd" <?php if (get_option('ddle_sort') == "catd") echo "checked='checked'"; ?> />&nbsp;&nbsp; By category (descending)<br />
		<input name="ddle_sort" type="radio" value="datea" <?php if (get_option('ddle_sort') == "datea") echo "checked='checked'"; ?> />&nbsp;&nbsp; By date (ascending)<br />
		<input name="ddle_sort" type="radio" value="dated" <?php if (get_option('ddle_sort') == "dated") echo "checked='checked'"; ?> />&nbsp;&nbsp; By date (descending)<br />
	</td></tr>

	<tr valign="top"><td width="35%" align="right">
		Show link to comments
	</td><td align="left">
		<input type="checkbox" name="ddle_comment_link" value="checkbox" <?php if (get_option('ddle_comment_link')) echo "checked='checked'"; ?>/>
	</td></tr>
		
	<tr valign="top"><td width="35%" align="right">
		Include number of comments
	</td><td align="left">
		<input type="checkbox" name="ddle_comment_num" value="checkbox" <?php if (get_option('ddle_comment_num')) echo "checked='checked'"; ?>/> 
	</td></tr>

	<tr valign="top"><td width="35%" align="right">		
		Include link for posts with no comments
	</td><td align="left">
		<input type="checkbox" name="ddle_comments_none" value="checkbox" <?php if (get_option('ddle_comments_none')) echo "checked='checked'"; ?>/>
	</td></tr>		

	</table>



	<table width="100%" border="0" cellspacing="0" cellpadding="6">



	<tr valign="top"><td width="35%" align="right">
		Turn category names into links
	</td><td align="left">
		<input type="checkbox" name="ddle_cat_links" value="checkbox" <?php if (get_option('ddle_cat_links')) echo "checked='checked'"; ?>/>
	</td></tr>	

	<tr valign="top"><td width="35%" align="right">
		Hide password-protected posts
	</td><td align="left">
		<input type="checkbox" name="ddle_hide_protected" value="checkbox" <?php if (get_option('ddle_hide_protected')) echo "checked='checked'"; ?>/>
	</td></tr>

	<tr valign="top"><td width="35%" align="right">
		Show date after listed posts
	</td><td align="left">
		<input type="checkbox" name="ddle_show_date" value="checkbox" <?php if (get_option('ddle_show_date')) echo "checked='checked'"; ?>/>
	</td></tr>

	<tr valign="top"><td width="35%" align="right">
		Date format
	</td><td align="left">
		<input name="ddle_date_format" type="text" size="30" value="<?php echo get_option('ddle_date_format') ?>"/>
		<br />( Use the standard <a href="http://us3.php.net/date">PHP date() format</a> )
	</td></tr>

	<tr valign="top"><td width="35%" align="right">
		Show first X characters of posts
	</td><td align="left">
		<input type="checkbox" name="ddle_excerpts" value="checkbox" <?php if (get_option('ddle_excerpts')) echo "checked='checked'"; ?>/>
	</td></tr>

	<tr valign="top"><td width="35%" align="right">
		Number of characters to show
	</td><td align="left">
		<input name="ddle_chars" type="text" size="10" value="<?php echo get_option('ddle_chars') ?>"/>
	</td></tr>

	<tr valign="top"><td width="35%" align="right">
		Limit list to X categories
	</td><td align="left">
		<input name="ddle_limit" type="text" size="10" value="<?php echo get_option('ddle_limit') ?>"/>
		(0 = unlimited)
	</td></tr>

	
	</table>
	</fieldset>

	<div class="submit">
		<input type="submit" name="set_defaults" value="<?php _e('Load Default Options'); ?> &raquo;" />
		<input type="submit" name="info_update" value="<?php _e('Update options'); ?> &raquo;" />
	</div>

	</form>
	</div><?php
}



function dd_last_from_each() {

	global $wpdb, $post, $wp_version;

	$ver = (float)$wp_version;
	
	$tp = $wpdb->prefix;

	$ddle_header = get_option('ddle_header');
	$ddle_sort = get_option('ddle_sort');
	$ddle_cat_links = get_option('ddle_cat_links');
	$ddle_hide_protected = get_option('ddle_hide_protected');
	$ddle_show_date = get_option('ddle_show_date');
	$ddle_date_format = get_option('ddle_date_format');
	$ddle_excerpts = get_option('ddle_excerpts');
	$ddle_chars = (int)get_option('ddle_chars');
	$ddle_comment_link = (bool)get_option('ddle_comment_link');
	$ddle_comment_num = (bool)get_option('ddle_comment_num');
	$ddle_comments_none = (bool)get_option('ddle_comments_none');
	$ddle_limit = (int)get_option('ddle_limit');


	$hide_check = '';
	if ($ddle_hide_protected) {
		$hide_check = " AND post_password = '' ";
	}	

	$sort_code = 'ORDER BY cat_name ASC, post_date DESC';

	switch ($ddle_sort) {
		case 'cata':
			$sort_code = 'GROUP BY cat_name, post_date DESC';			
			break; 
		case 'catd':
			$sort_code = 'ORDER BY cat_name DESC, post_date DESC';		
			break;	
		case 'datea':
			$sort_code = 'ORDER BY post_date ASC'; 						
			break;	
		case 'dated':
			$sort_code = 'ORDER BY post_date DESC';						 
			break;	
	}	

	$the_output = NULL;


	if ($ver < 2.3) {

		$last_posts = (array)$wpdb->get_results("
			SELECT post_date, ID, post_title, cat_name, cat_ID
			FROM {$tp}posts, {$tp}post2cat, {$tp}categories 
			WHERE {$tp}posts.ID = {$tp}post2cat.post_id 
			AND {$tp}categories.cat_ID = {$tp}post2cat.category_id
			AND post_status = 'publish' 
			AND post_type != 'page' 
			AND post_date < NOW() 
			{$hide_check} 
			{$sort_code}
		");

	} else { // post 2.3

		$last_posts = (array)$wpdb->get_results("
			SELECT post_date, 
				ID, 
				post_title, 
				{$tp}terms.name as cat_name, 
				{$tp}terms.term_id as cat_ID
			FROM {$tp}posts, {$tp}terms, {$tp}term_taxonomy, {$tp}term_relationships
			WHERE {$tp}posts.ID = {$tp}term_relationships.object_id 
			AND {$tp}term_relationships.object_id = {$tp}posts.ID
			AND {$tp}term_relationships.term_taxonomy_id = {$tp}term_taxonomy.term_taxonomy_id 
			AND {$tp}terms.term_id  = {$tp}term_taxonomy.term_id 
			AND {$tp}term_taxonomy.taxonomy = 'category' 
			AND post_status = 'publish' 
			AND post_type = 'post' 
			AND post_date < NOW() 
			{$hide_check} 
			{$sort_code}
		");


	}

	if (empty($last_posts)) {
		return NULL;
	}


	$the_output .= stripslashes($ddle_header); 



		if ($ddle_sort == 'datea') {
			$last_posts = array_reverse($last_posts);
		}



	$used_cats = array();;
	$i = 0;
	foreach ($last_posts as $posts) {

		if (in_array($posts->cat_name, $used_cats)) {
			unset($last_posts[$i]);
		} else {
			$used_cats[] = $posts->cat_name;
		}

		$i++;
	}
	$last_posts = array_values($last_posts);



		if ($ddle_sort == 'datea') {
			$last_posts = array_reverse($last_posts);
		}



	$the_output .= '<ul>';

	$limit_check = 0;

	foreach ($last_posts as $posts) {

		if (($ddle_limit == 0) || ($limit_check < $ddle_limit)) {



	
		$the_output .= '   <li><b>';

		if ($ddle_cat_links) {
			$the_output .= '<a href="' . get_category_link($posts->cat_ID) . '">' . $posts->cat_name . '</a>';
		} else {
			$the_output .= $posts->cat_name;
		}

		$the_output .= '</b>: <a href="' . get_permalink($posts->ID) . '">' . $posts->post_title . '</a>';

		if ($ddle_show_date) {
			$the_output .= ' - ' . date_i18n($ddle_date_format, strtotime($posts->post_date)); 
		}


		if ($ddle_comment_link) {

	        $result = "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1' AND comment_post_ID = '" . $posts->ID . "'"; 

			$num_comments = $wpdb->get_var($result);

			if ($ddle_comments_none || ($num_comments != 0)) {

				$the_output .= ' - <a href="' . get_permalink($posts->ID) . '#comments">';

				if ($ddle_comment_num) {

					$the_output .= $num_comments . ' Comment';

					if ($num_comments != 1) {
						$the_output .= 's';
					}

				} else {
					$the_output .= 'Comments';
				}

				$the_output .= '</a>';

			}


		}


		if ($ddle_excerpts) {

			$the_text = $wpdb->get_var("SELECT post_content FROM " . $tp . "posts WHERE ID=" . $posts->ID);
			$the_output .= '<br />';
			$the_output .= substr(strip_tags(trim($the_text)) , 0, $ddle_chars);
			if (strlen(strip_tags(trim($the_text))) > $ddle_chars) {
				$the_output .= "...";
			}
		}

		$the_output .= '</li>';




		} // end limit if

		$limit_check++;

	}

	$the_output .= '</ul>';





	return $the_output;


}






function ddle_generate($content) {

	if (strpos($content, "<!-- ddlastfromeach -->") !== FALSE) {
		$content = str_replace("<!-- ddlastfromeach -->", dd_last_from_each(), $content);
	}

	return $content;
}




add_filter('the_content', 'ddle_generate');


add_action('admin_menu', 'ddle_add_option_pages'); 






?>