WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to use the edit-tags.php search function with multiple term id's. For example, if i type into the searchbox something like this: #1245&6832, it should display these two terms in the results table(WP_Terms_List_Table).

I tried to use the pre_get_posts action to get access to the query that is running for the search, but this is just showing me an "empty" query:

add_action('pre_get_posts', 'filter_terms_by_ids' );

function filter_terms_by_ids( $wp_query ) {
    global $pagenow;

    if($pagenow == 'edit-tags.php' && $_GET['s']):


My idea is to check the $_GET['s'] and if # is the first character, i can modify the query to only include these terms in the search:

if ('#' == substr($_GET['s'],0,1))
share|improve this question
up vote 1 down vote accepted

It's easy to implement. All you need is your own hook for get_terms_args filter:

add_filter( 'get_terms_args', 'wpse8170_get_terms_args', 10, 2  );
function wpse8170_get_terms_args( $args, $taxonomies ) {
    if ( !in_array( 'post_tag', $taxonomies ) ) {
        return $args;

    $matches = array();
    if ( empty( $args['search'] ) || !preg_match( '/^\#(.*)$/', $args['search'], $matches ) ) {
        return $args;

    if ( count( $matches ) == 2 ) {
        $args['search'] = '';
        $args['include'] = array_filter( array_map( 'intval', explode( '&', $matches[1] ) ) );

    return $args;
share|improve this answer
Thanks, works as excepted, i just needed to change post_tag to my taxonomy name. – passatgt Jan 11 '13 at 17:39
@passatgt u r welcome – Eugene Manuilov Jan 11 '13 at 18:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.