Make WordPress Core


Ignore:
Timestamp:
05/29/2007 04:25:09 AM (19 years ago)
Author:
ryan
Message:

get_objects_in_term()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/taxonomy.php

    r5567 r5585  
    365365
    366366        return $tt_ids;
     367}
     368
     369function get_objects_in_term( $terms, $taxonomies, $args = array() ) {
     370        global $wpdb;
     371
     372        if ( !is_array( $terms) )
     373                $terms = array($terms);
     374
     375        if ( !is_array($taxonomies) )
     376                $taxonomies = array($taxonomies);
     377
     378        $defaults = array('order' => 'ASC');
     379        $args = wp_parse_args( $args, $defaults );
     380        extract($args);
     381
     382        $taxonomies = "'" . implode("', '", $taxonomies) . "'";
     383        $terms = "'" . implode("', '", $terms) . "'";
     384
     385        $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 ($in_terms) ORDER BY tr.object_id $order");
     386
     387        if ( ! $object_ids )
     388                return array();
     389
     390        return $object_ids;
    367391}
    368392
Note: See TracChangeset for help on using the changeset viewer.