[wp-trac] [WordPress Trac] #28232: Custom Taxonomy filter on post listing pages
WordPress Trac
noreply at wordpress.org
Mon Nov 5 23:17:13 UTC 2018
#28232: Custom Taxonomy filter on post listing pages
-----------------------------------------+-----------------------------
Reporter: jtsternberg | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Future Release
Component: Taxonomy | Version:
Severity: normal | Resolution:
Keywords: needs-patch has-ui-feedback | Focuses: administration
-----------------------------------------+-----------------------------
Comment (by drzraf):
The query tweak needed is here: http://scribu.net/wordpress/sortable-
taxonomy-columns.html
{{{
#!sql
$clauses['join'] .= <<<SQL
LEFT OUTER JOIN {$wpdb->term_relationships} ON
{$wpdb->posts}.ID={$wpdb->term_relationships}.object_id
LEFT OUTER JOIN {$wpdb->term_taxonomy} USING (term_taxonomy_id)
LEFT OUTER JOIN {$wpdb->terms} USING (term_id)
SQL;
$clauses['where'] .= " AND (taxonomy = 'color' OR taxonomy
IS NULL)";
$clauses['groupby'] = "object_id";
$clauses['orderby'] = "GROUP_CONCAT({$wpdb->terms}.name
ORDER BY name ASC) ";
$clauses['orderby'] .= ( 'ASC' == strtoupper(
$wp_query->get('order') ) ) ? 'ASC' : 'DESC';
}}}
What is needed is an easy and structured way to wrap and this kind of
information to a `WP_Query` without messing-up with other existing query
parameters.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/28232#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list