[BUG FOUND SOLUTION] – Problem when using custom prefix
-
i’m using it with wordpress v3.9 and found problem when using custom prefix table (not using “wp_” prefix)
The problem lies in category filter it using plain wp_ query:
$rows = $wpdb->get_results("SELECT wp_terms.name, wp_term_taxonomy.term_taxonomy_id FROM wp_terms, wp_term_taxonomy WHERE wp_terms.term_id=wp_term_taxonomy.term_id AND wp_term_taxonomy.taxonomy='category' ");
Solution:
Around line 114, change:$table_name = $wpdb->prefix . "terms"; $rows = $wpdb->get_results("SELECT wp_terms.name, wp_term_taxonomy.term_taxonomy_id FROM wp_terms, wp_term_taxonomy WHERE wp_terms.term_id=wp_term_taxonomy.term_id AND wp_term_taxonomy.taxonomy='category' ");
TO
$table_name = $wpdb->prefix . "terms"; $table_name_taxonomy = $wpdb->prefix . "term"; $rows = $wpdb->get_results("SELECT ".$table_name.".name, ".$table_name_taxonomy."_taxonomy.term_taxonomy_id FROM ".$table_name.", ".$table_name_taxonomy."_taxonomy WHERE ".$table_name.".term_id=".$table_name_taxonomy."_taxonomy.term_id AND ".$table_name_taxonomy."_taxonomy.taxonomy='category'");
Around line 138:
CHANGE:$rows_id = $wpdb->get_results("SELECT term_taxonomy_id FROM wp_term_relationships ");
TO
$rows_id = $wpdb->get_results("SELECT term_taxonomy_id FROM ".$table_name_taxonomy."_relationships ");
Hope this helps
- The topic ‘[BUG FOUND SOLUTION] – Problem when using custom prefix’ is closed to new replies.