mirror of
https://github.com/10h30/display-featured-image-genesis.git
synced 2026-07-11 18:46:03 +09:00
add sort taxonomies by taxonomy, then term
need to decide if this is helpful for items with multiple terms/taxes assigned. Think in this case, the user will have to pick a featured image for the singular post anyway if they really care which one gets assigned.
This commit is contained in:
@@ -73,13 +73,15 @@ class Display_Featured_Image_Genesis_Common {
|
||||
}
|
||||
elseif ( ! has_post_thumbnail() || $width <= $item->medium ) {
|
||||
$taxonomies = get_taxonomies();
|
||||
$args = array( 'fields' => 'ids', 'orderby' => 'term_group', 'order' => 'DESC' );
|
||||
$args = array( 'orderby' => 'term_group', 'order' => 'ASC' );
|
||||
$terms = wp_get_object_terms( get_the_ID(), $taxonomies, $args );
|
||||
usort( $terms, array( __CLASS__, 'tax_term_compare' ) );
|
||||
|
||||
foreach ( $terms as $t_id ) {
|
||||
foreach ( $terms as $term ) {
|
||||
$t_id = $term->term_id;
|
||||
$term_meta = get_option( "taxonomy_$t_id" );
|
||||
if ( $term_meta['dfig_image'] ) {
|
||||
$image_id = Display_Featured_Image_Genesis_Common::get_image_id( $term_meta['dfig_image'] );
|
||||
$image_id = self::get_image_id( $term_meta['dfig_image'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -154,6 +156,20 @@ class Display_Featured_Image_Genesis_Common {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* compare multiple taxonomies
|
||||
* @param taxonomy $a each taxonomy assigned to a post
|
||||
* @param name $b the slug of each taxonomy
|
||||
* @return list list of terms, ordered by taxonomy, then slug
|
||||
* @since x.y.z
|
||||
*/
|
||||
protected static function tax_term_compare( $a, $b ) {
|
||||
if ( $a->taxonomy == $b->name ) {
|
||||
return ( $a->taxonomy < $b->name ) ? -1 : 1;
|
||||
}
|
||||
return ( $a->taxonomy < $b->name ) ? -1 : 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the ID of each image dynamically.
|
||||
|
||||
Reference in New Issue
Block a user