get_objects_in_term

The timeline below displays how wordpress function get_objects_in_term has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.3

//
// Term API.
//
/**
 * Retrieves object IDs of valid taxonomy and term.
 *
 * The strings of `$taxonomies` must exist before this function will continue.
 * On failure of finding a valid taxonomy, it will return a WP_Error.
 *
 * The `$terms` aren't checked the same as `$taxonomies`, but still need to exist
 * for object IDs to be returned.
 *
 * It is possible to change the order that object IDs are returned by using `$args`
 * with either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|int[]       $term_ids   Term ID or array of term IDs of terms that will be used.
 * @param string|string[] $taxonomies String of taxonomy name or Array of string values of taxonomy names.
 * @param array|string    $args       {
 *     Change the order of the object IDs.
 *
 *     @type string $order Order to retrieve terms. Accepts 'ASC' or 'DESC'. Default 'ASC'.
 * }
 * @return string[]|WP_Error An array of object IDs as numeric strings on success,
 *                           WP_Error if the taxonomy does not exist.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' === strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $sql = "SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}";
    $last_changed = wp_cache_get_last_changed('terms');
    $cache_key = 'get_objects_in_term:' . md5($sql) . ":{$last_changed}";
    $cache = wp_cache_get($cache_key, 'term-queries');
    if (false === $cache) {
        $object_ids = $wpdb->get_col($sql);
        wp_cache_set($cache_key, $object_ids, 'term-queries');
    } else {
        $object_ids = (array) $cache;
    }
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 6.1

//
// Term API.
//
/**
 * Retrieves object IDs of valid taxonomy and term.
 *
 * The strings of `$taxonomies` must exist before this function will continue.
 * On failure of finding a valid taxonomy, it will return a WP_Error.
 *
 * The `$terms` aren't checked the same as `$taxonomies`, but still need to exist
 * for object IDs to be returned.
 *
 * It is possible to change the order that object IDs are returned by using `$args`
 * with either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|int[]       $term_ids   Term ID or array of term IDs of terms that will be used.
 * @param string|string[] $taxonomies String of taxonomy name or Array of string values of taxonomy names.
 * @param array|string    $args       Change the order of the object IDs, either ASC or DESC.
 * @return string[]|WP_Error An array of object IDs as numeric strings on success,
 *                           WP_Error if the taxonomy does not exist.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' === strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $sql = "SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}";
    $last_changed = wp_cache_get_last_changed('terms');
    $cache_key = 'get_objects_in_term:' . md5($sql) . ":{$last_changed}";
    $cache = wp_cache_get($cache_key, 'terms');
    if (false === $cache) {
        $object_ids = $wpdb->get_col($sql);
        wp_cache_set($cache_key, $object_ids, 'terms');
    } else {
        $object_ids = (array) $cache;
    }
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 5.9

//
// Term API.
//
/**
 * Retrieve object IDs of valid taxonomy and term.
 *
 * The strings of `$taxonomies` must exist before this function will continue.
 * On failure of finding a valid taxonomy, it will return a WP_Error.
 *
 * The `$terms` aren't checked the same as `$taxonomies`, but still need to exist
 * for object IDs to be returned.
 *
 * It is possible to change the order that object IDs are returned by using `$args`
 * with either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|int[]       $term_ids   Term ID or array of term IDs of terms that will be used.
 * @param string|string[] $taxonomies String of taxonomy name or Array of string values of taxonomy names.
 * @param array|string    $args       Change the order of the object IDs, either ASC or DESC.
 * @return string[]|WP_Error An array of object IDs as numeric strings on success,
 *                           WP_Error if the taxonomy does not exist.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' === strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $sql = "SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}";
    $last_changed = wp_cache_get_last_changed('terms');
    $cache_key = 'get_objects_in_term:' . md5($sql) . ":{$last_changed}";
    $cache = wp_cache_get($cache_key, 'terms');
    if (false === $cache) {
        $object_ids = $wpdb->get_col($sql);
        wp_cache_set($cache_key, $object_ids, 'terms');
    } else {
        $object_ids = (array) $cache;
    }
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 5.7

//
// Term API.
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue.
 * On failure of finding a valid taxonomy, it will return a WP_Error class,
 * kind of like Exceptions in PHP 5, except you can't catch them. Even so,
 * you can still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array    $term_ids   Term ID or array of term IDs of terms that will be used.
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names.
 * @param array|string $args       Change the order of the object_ids, either ASC or DESC.
 * @return array|WP_Error An array of $object_ids on success, WP_Error if the taxonomy does not exist.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' === strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $sql = "SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}";
    $last_changed = wp_cache_get_last_changed('terms');
    $cache_key = 'get_objects_in_term:' . md5($sql) . ":{$last_changed}";
    $cache = wp_cache_get($cache_key, 'terms');
    if (false === $cache) {
        $object_ids = $wpdb->get_col($sql);
        wp_cache_set($cache_key, $object_ids, 'terms');
    } else {
        $object_ids = (array) $cache;
    }
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 5.5

//
// Term API.
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array    $term_ids   Term ID or array of term IDs of terms that will be used.
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names.
 * @param array|string $args       Change the order of the object_ids, either ASC or DESC.
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success.
 *  the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' === strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $sql = "SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}";
    $last_changed = wp_cache_get_last_changed('terms');
    $cache_key = 'get_objects_in_term:' . md5($sql) . ":{$last_changed}";
    $cache = wp_cache_get($cache_key, 'terms');
    if (false === $cache) {
        $object_ids = $wpdb->get_col($sql);
        wp_cache_set($cache_key, $object_ids, 'terms');
    } else {
        $object_ids = (array) $cache;
    }
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 5.4

//
// Term API.
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array    $term_ids   Term id or array of term ids of terms that will be used.
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names.
 * @param array|string $args       Change the order of the object_ids, either ASC or DESC.
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success.
 *  the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' === strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $sql = "SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}";
    $last_changed = wp_cache_get_last_changed('terms');
    $cache_key = 'get_objects_in_term:' . md5($sql) . ":{$last_changed}";
    $cache = wp_cache_get($cache_key, 'terms');
    if (false === $cache) {
        $object_ids = $wpdb->get_col($sql);
        wp_cache_set($cache_key, $object_ids, 'terms');
    } else {
        $object_ids = (array) $cache;
    }
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 5.3

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array    $term_ids   Term id or array of term ids of terms that will be used.
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names.
 * @param array|string $args       Change the order of the object_ids, either ASC or DESC.
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success.
 *  the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' === strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $sql = "SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}";
    $last_changed = wp_cache_get_last_changed('terms');
    $cache_key = 'get_objects_in_term:' . md5($sql) . ":{$last_changed}";
    $cache = wp_cache_get($cache_key, 'terms');
    if (false === $cache) {
        $object_ids = $wpdb->get_col($sql);
        wp_cache_set($cache_key, $object_ids, 'terms');
    } else {
        $object_ids = (array) $cache;
    }
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 5.1

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array    $term_ids   Term id or array of term ids of terms that will be used.
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names.
 * @param array|string $args       Change the order of the object_ids, either ASC or DESC.
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success.
 *  the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $sql = "SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}";
    $last_changed = wp_cache_get_last_changed('terms');
    $cache_key = 'get_objects_in_term:' . md5($sql) . ":{$last_changed}";
    $cache = wp_cache_get($cache_key, 'terms');
    if (false === $cache) {
        $object_ids = $wpdb->get_col($sql);
        wp_cache_set($cache_key, $object_ids, 'terms');
    } else {
        $object_ids = (array) $cache;
    }
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 4.9

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array    $term_ids   Term id or array of term ids of terms that will be used.
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names.
 * @param array|string $args       Change the order of the object_ids, either ASC or DESC.
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success.
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $sql = "SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}";
    $last_changed = wp_cache_get_last_changed('terms');
    $cache_key = 'get_objects_in_term:' . md5($sql) . ":{$last_changed}";
    $cache = wp_cache_get($cache_key, 'terms');
    if (false === $cache) {
        $object_ids = $wpdb->get_col($sql);
        wp_cache_set($cache_key, $object_ids, 'terms');
    } else {
        $object_ids = (array) $cache;
    }
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 4.6

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array    $term_ids   Term id or array of term ids of terms that will be used.
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names.
 * @param array|string $args       Change the order of the object_ids, either ASC or DESC.
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success.
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: .20

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array    $term_ids   Term id or array of term ids of terms that will be used.
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names.
 * @param array|string $args       Change the order of the object_ids, either ASC or DESC.
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success.
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 4.2

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array    $term_ids   Term id or array of term ids of terms that will be used.
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names.
 * @param array|string $args       Change the order of the object_ids, either ASC or DESC.
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success.
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", $taxonomies) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: .10

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array    $term_ids   Term id or array of term ids of terms that will be used.
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names.
 * @param array|string $args       Change the order of the object_ids, either ASC or DESC.
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success.
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 4.4

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array    $term_ids   Term id or array of term ids of terms that will be used.
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names.
 * @param array|string $args       Change the order of the object_ids, either ASC or DESC.
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success.
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", $taxonomies) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: .30

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array    $term_ids   Term id or array of term ids of terms that will be used.
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names.
 * @param array|string $args       Change the order of the object_ids, either ASC or DESC.
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success.
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 3.3

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array    $term_ids   Term id or array of term ids of terms that will be used.
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names.
 * @param array|string $args       Change the order of the object_ids, either ASC or DESC.
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success.
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", $taxonomies) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: .20

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array    $term_ids   Term id or array of term ids of terms that will be used.
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names.
 * @param array|string $args       Change the order of the object_ids, either ASC or DESC.
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success.
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 3.2

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array    $term_ids   Term id or array of term ids of terms that will be used.
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names.
 * @param array|string $args       Change the order of the object_ids, either ASC or DESC.
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success.
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", $taxonomies) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: .10

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array    $term_ids   Term id or array of term ids of terms that will be used.
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names.
 * @param array|string $args       Change the order of the object_ids, either ASC or DESC.
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success.
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 4.3

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array    $term_ids   Term id or array of term ids of terms that will be used.
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names.
 * @param array|string $args       Change the order of the object_ids, either ASC or DESC.
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success.
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", $taxonomies) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 2.8

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 2.4

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", $taxonomies) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: .30

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 2.3

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", $taxonomies) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: .20

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 2.2

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", $taxonomies) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: .10

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 1.5

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", $taxonomies) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: .40

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 1.4

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", $taxonomies) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: .30

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 1.3

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", $taxonomies) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: .20

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 1.2

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", $taxonomies) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: .11

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 4.1

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", $taxonomies) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 0.4

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @uses $wpdb
 * @uses wp_parse_args() Creates an array from string $args.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", $taxonomies) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: .30

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @uses $wpdb
 * @uses wp_parse_args() Creates an array from string $args.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 0.3

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @uses $wpdb
 * @uses wp_parse_args() Creates an array from string $args.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", $taxonomies) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: .20

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @uses $wpdb
 * @uses wp_parse_args() Creates an array from string $args.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 0.2

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @uses $wpdb
 * @uses wp_parse_args() Creates an array from string $args.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", $taxonomies) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: .11

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @uses $wpdb
 * @uses wp_parse_args() Creates an array from string $args.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 4.0

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @uses $wpdb
 * @uses wp_parse_args() Creates an array from string $args.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    $order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", $taxonomies) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 9.2

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @uses $wpdb
 * @uses wp_parse_args() Creates an array from string $args.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    $order = ('desc' == strtolower($order)) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", $taxonomies) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: .12

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @uses $wpdb
 * @uses wp_parse_args() Creates an array from string $args.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    $order = ('desc' == strtolower($order)) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 3.9

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @since 2.3.0
 *
 * @uses $wpdb
 * @uses wp_parse_args() Creates an array from string $args.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    $order = ('desc' == strtolower($order)) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", $taxonomies) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 8.4

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @package WordPress
 * @subpackage Taxonomy
 * @since 2.3.0
 *
 * @uses $wpdb
 * @uses wp_parse_args() Creates an array from string $args.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    $order = ('desc' == strtolower($order)) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", $taxonomies) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: .30

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @package WordPress
 * @subpackage Taxonomy
 * @since 2.3.0
 *
 * @uses $wpdb
 * @uses wp_parse_args() Creates an array from string $args.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    $order = ('desc' == strtolower($order)) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 8.3

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @package WordPress
 * @subpackage Taxonomy
 * @since 2.3.0
 *
 * @uses $wpdb
 * @uses wp_parse_args() Creates an array from string $args.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    $order = ('desc' == strtolower($order)) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", $taxonomies) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: .20

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @package WordPress
 * @subpackage Taxonomy
 * @since 2.3.0
 *
 * @uses $wpdb
 * @uses wp_parse_args() Creates an array from string $args.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    $order = ('desc' == strtolower($order)) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 8.2

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @package WordPress
 * @subpackage Taxonomy
 * @since 2.3.0
 *
 * @uses $wpdb
 * @uses wp_parse_args() Creates an array from string $args.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    $order = ('desc' == strtolower($order)) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", $taxonomies) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: .14

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @package WordPress
 * @subpackage Taxonomy
 * @since 2.3.0
 *
 * @uses $wpdb
 * @uses wp_parse_args() Creates an array from string $args.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    $order = ('desc' == strtolower($order)) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 7.5

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @package WordPress
 * @subpackage Taxonomy
 * @since 2.3.0
 *
 * @uses $wpdb
 * @uses wp_parse_args() Creates an array from string $args.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    $order = ('desc' == strtolower($order)) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", $taxonomies) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: .40

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @package WordPress
 * @subpackage Taxonomy
 * @since 2.3.0
 *
 * @uses $wpdb
 * @uses wp_parse_args() Creates an array from string $args.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    $order = ('desc' == strtolower($order)) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 7.4

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @package WordPress
 * @subpackage Taxonomy
 * @since 2.3.0
 *
 * @uses $wpdb
 * @uses wp_parse_args() Creates an array from string $args.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    $order = ('desc' == strtolower($order)) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", $taxonomies) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: .30

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @package WordPress
 * @subpackage Taxonomy
 * @since 2.3.0
 *
 * @uses $wpdb
 * @uses wp_parse_args() Creates an array from string $args.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    $order = ('desc' == strtolower($order)) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 7.3

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @package WordPress
 * @subpackage Taxonomy
 * @since 2.3.0
 *
 * @uses $wpdb
 * @uses wp_parse_args() Creates an array from string $args.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    $order = ('desc' == strtolower($order)) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", $taxonomies) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: .20

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @package WordPress
 * @subpackage Taxonomy
 * @since 2.3.0
 *
 * @uses $wpdb
 * @uses wp_parse_args() Creates an array from string $args.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    $order = ('desc' == strtolower($order)) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 7.2

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @package WordPress
 * @subpackage Taxonomy
 * @since 2.3.0
 *
 * @uses $wpdb
 * @uses wp_parse_args() Creates an array from string $args.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    $order = ('desc' == strtolower($order)) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", $taxonomies) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: .14

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @package WordPress
 * @subpackage Taxonomy
 * @since 2.3.0
 *
 * @uses $wpdb
 * @uses wp_parse_args() Creates an array from string $args.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    $order = ('desc' == strtolower($order)) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", array_map('esc_sql', $taxonomies)) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}

WordPress Version: 3.7

//
// Term API
//
/**
 * Retrieve object_ids of valid taxonomy and term.
 *
 * The strings of $taxonomies must exist before this function will continue. On
 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
 * still test for the WP_Error class and get the error message.
 *
 * The $terms aren't checked the same as $taxonomies, but still need to exist
 * for $object_ids to be returned.
 *
 * It is possible to change the order that object_ids is returned by either
 * using PHP sort family functions or using the database by using $args with
 * either ASC or DESC array. The value should be in the key named 'order'.
 *
 * @package WordPress
 * @subpackage Taxonomy
 * @since 2.3.0
 *
 * @uses $wpdb
 * @uses wp_parse_args() Creates an array from string $args.
 *
 * @param int|array $term_ids Term id or array of term ids of terms that will be used
 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
 * @param array|string $args Change the order of the object_ids, either ASC or DESC
 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
 *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
 */
function get_objects_in_term($term_ids, $taxonomies, $args = array())
{
    global $wpdb;
    if (!is_array($term_ids)) {
        $term_ids = array($term_ids);
    }
    if (!is_array($taxonomies)) {
        $taxonomies = array($taxonomies);
    }
    foreach ((array) $taxonomies as $taxonomy) {
        if (!taxonomy_exists($taxonomy)) {
            return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
        }
    }
    $defaults = array('order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    $order = ('desc' == strtolower($order)) ? 'DESC' : 'ASC';
    $term_ids = array_map('intval', $term_ids);
    $taxonomies = "'" . implode("', '", $taxonomies) . "'";
    $term_ids = "'" . implode("', '", $term_ids) . "'";
    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ({$taxonomies}) AND tt.term_id IN ({$term_ids}) ORDER BY tr.object_id {$order}");
    if (!$object_ids) {
        return array();
    }
    return $object_ids;
}