WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Drop-Down Post List Plugin duplicate posts (2 posts)

  1. kgagne
    Member
    Posted 4 years ago #

    I'm using v1.33 of this plugin on WordPress 2.9.2 to create a dropdown "jump" list of recent blog posts in my sidebar:

    http://www.dagondesign.com/articles/drop-down-post-list-plugin-for-wordpress/

    It appears that, when a post is filed under more than one category, it will appear in the dropdown's list once for each category. Has anyone else had this issue or encountered a fix?

    I don't know much about PHP or SQL, but I'm guessing there's something amiss with this part of the code (lines 238-256 in dd-drop-down-post-list.php):

    $cat_sel_code = ' ';
    		if (!$all_cats) {
    			$cat_sel_code = " AND {$table_prefix}term_taxonomy.term_id = {$catID} ";
    		}
    
    		$post_list = (array)$wpdb->get_results("
    			SELECT ID,
    				post_title,
    				post_date
    			FROM {$table_prefix}posts, {$table_prefix}term_relationships, {$table_prefix}term_taxonomy
    			WHERE {$table_prefix}posts.ID = {$table_prefix}term_relationships.object_id
    			AND {$table_prefix}term_relationships.term_taxonomy_id = {$table_prefix}term_taxonomy.term_taxonomy_id
    			AND {$table_prefix}term_taxonomy.taxonomy = 'category'
    			{$cat_sel_code}
    			AND post_status = 'publish'
    			AND post_type != 'page'
    			{$sort_code}
    			{$limit_code}
    		");
  2. kgagne
    Member
    Posted 4 years ago #

    Since I have this plugin set to display all categories, I was able to fix this problem by deleting the category selection code entirely. The replacement for the aforementioned code block is

    $cat_sel_code = ' ';
    		if (!$all_cats) {
    			$cat_sel_code = " AND {$table_prefix}term_taxonomy.term_id = {$catID} ";
    		}
    
    		$post_list = (array)$wpdb->get_results("
    			SELECT ID,
    				post_title,
    				post_date
    			FROM {$table_prefix}posts WHERE post_status = 'publish'
    			AND post_type != 'page'
    			{$sort_code}
    			{$limit_code}
    		");

Topic Closed

This topic has been closed to new replies.

About this Topic