mirror of
https://github.com/10h30/display-featured-image-genesis.git
synced 2026-06-05 15:08:20 +09:00
change get_object_terms to get the image from most used taxonomy
This commit is contained in:
@@ -60,7 +60,7 @@ class Display_Featured_Image_Genesis_Common {
|
||||
$image_id = $postspage_image;
|
||||
}
|
||||
// taxonomy
|
||||
elseif ( is_category() || is_tax() ) {
|
||||
elseif ( is_category() || is_tag() || is_tax() ) {
|
||||
$term = get_queried_object();
|
||||
$t_id = $term->term_id;
|
||||
$term_meta = get_option( "taxonomy_$t_id" );
|
||||
@@ -73,9 +73,8 @@ class Display_Featured_Image_Genesis_Common {
|
||||
}
|
||||
elseif ( ! has_post_thumbnail() || $width <= $item->medium ) {
|
||||
$taxonomies = get_taxonomies();
|
||||
$args = array( 'orderby' => 'term_group', 'order' => 'ASC' );
|
||||
$args = array( 'orderby' => 'count', 'order' => 'ASC' );
|
||||
$terms = wp_get_object_terms( get_the_ID(), $taxonomies, $args );
|
||||
usort( $terms, array( __CLASS__, 'tax_term_compare' ) );
|
||||
|
||||
foreach ( $terms as $term ) {
|
||||
$t_id = $term->term_id;
|
||||
@@ -156,20 +155,6 @@ 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