[wp-trac] [WordPress Trac] #18747: Custom Taxonomy Search/Filter Bug
WordPress Trac
wp-trac at lists.automattic.com
Thu Sep 22 15:03:23 UTC 2011
#18747: Custom Taxonomy Search/Filter Bug
--------------------------------------+----------------------
Reporter: wordpressplugindeveloper | Owner:
Type: defect (bug) | Status: closed
Priority: normal | Milestone:
Component: Query | Version:
Severity: normal | Resolution: invalid
Keywords: |
--------------------------------------+----------------------
Comment (by scribu):
Ok, here's an alternative approach:
Define a new query var, 'business_id' and use the 'request' filter to
transform it into a 'tax_query':
{{{
define( 'MY_TAX_NAME', 'business' );
define( 'MY_TAX_QV', 'business_id' );
class My_Tax_Enhancement {
function init_qv() {
$GLOBALS['wp']->add_query_var( MY_TAX_QV );
}
function parse_qv( $request ) {
if ( isset( $request[MY_TAX_QV] ) ) {
$request['tax_query'] = array(
array(
'taxonomy' => MY_TAX_NAME,
'terms' => $request[MY_TAX_QV],
)
);
}
return $request;
}
}
add_filter( 'init', array( 'My_Tax_Enhancement', 'init_qv' ) );
add_filter( 'request', array( 'My_Tax_Enhancement', 'parse_qv' ) );
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/18747#comment:14>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list