Haho!
Adott a kovetkezo fuggveny (wp-includes/taxonomy.php) :
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;
}
Ezt szertnem ugy hasznalni/modositani (nyilvan nem az eredeti fuggvenyt), hogy csak azokat az objektumokat adja vissza, amik tartalmazzak az osszes tag-et nem csak az egyiket vagy a masikat.
Konkretan az ngg-gallery kepeit akarom igy listazni(szurni!) tag-ek alapjan.
Valahogy igy nezne ki a dolog:
<?php
$x=get_objects_in_term_intersection(array("141","144"), "ngg_tag");
Ha egy kep csak a 141-hez tartozik akkor nem kell, ha csak a 144-hez akkor sem. Csak akkor, ha mindkettohoz.
<?php
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;
}
Ezt szertnem ugy hasznalni/modositani (nyilvan nem az eredeti fuggvenyt), hogy csak azokat az objektumokat adja vissza, amik tartalmazzak az osszes tag-et nem csak az egyiket vagy a masikat.
Konkretan az ngg-gallery kepeit akarom igy listazni(szurni!) tag-ek alapjan.
Valahogy igy nezne ki a dolog:
<?php
$x=get_objects_in_term_intersection(array("141","144"), "ngg_tag");
Ha egy kep csak a 141-hez tartozik akkor nem kell, ha csak a 144-hez akkor sem. Csak akkor, ha mindkettohoz.
<?php
$x=get_objects_in_term_intersection(array("141","144"), "ngg_tag");
Ha egy kep csak a 141-hez tartozik akkor nem kell, ha csak a 144-hez akkor sem. Csak akkor, ha mindkettohoz.