Change post type getter

This commit is contained in:
Robin Cornett
2019-06-07 11:45:36 -04:00
parent e32fd015cf
commit e1ec44a6d3
@@ -110,8 +110,8 @@ class Display_Featured_Image_Genesis_Common {
}
// if a post type image exists, it takes priority over the fallback. check that next.
$post_type = get_post_type();
if ( isset( $setting['post_type'][ $post_type ] ) && $setting['post_type'][ $post_type ] ) {
$post_type = self::get_post_type();
if ( ! empty( $setting['post_type'][ $post_type ] ) ) {
/**
* Creates display_featured_image_genesis_use_post_type_image filter to check
* whether get_post_type array should use the post type image.
@@ -163,6 +163,20 @@ class Display_Featured_Image_Genesis_Common {
return $image_id;
}
/**
* Get the current post type.
* @return false|object|string
*/
private static function get_post_type() {
$post_type = get_post_type();
if ( ! is_post_type_archive() ) {
return $post_type;
}
$post_type = get_queried_object();
return $post_type->name;
}
/**
* Get the featured image for the singular post
* @param $image_id int|string