mirror of
https://github.com/10h30/display-featured-image-genesis.git
synced 2026-06-05 15:08:20 +09:00
Add posts featured image if no blog page is set
This commit is contained in:
@@ -88,15 +88,15 @@ class Display_Featured_Image_Genesis_Common {
|
|||||||
// outlier: if it's a home page with a static front page, and there is a featured image set on the home page
|
// outlier: if it's a home page with a static front page, and there is a featured image set on the home page
|
||||||
// also provisionally sets featured image for posts, similar to CPT archives
|
// also provisionally sets featured image for posts, similar to CPT archives
|
||||||
$frontpage = get_option( 'show_on_front' ); // either 'posts' or 'page'
|
$frontpage = get_option( 'show_on_front' ); // either 'posts' or 'page'
|
||||||
if ( 'page' === $frontpage ) {
|
$postspage = get_option( 'page_for_posts' );
|
||||||
$postspage = get_option( 'page_for_posts' );
|
if ( 'page' === $frontpage && $postspage ) {
|
||||||
$postspage_image = get_post_thumbnail_id( $postspage );
|
$postspage_image = get_post_thumbnail_id( $postspage );
|
||||||
$setting['post_type']['post'] = (int) $postspage_image;
|
$setting['post_type']['post'] = (int) $postspage_image;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if a post type image exists, it takes priority over the fallback. check that next.
|
// if a post type image exists, it takes priority over the fallback. check that next.
|
||||||
$post_type = get_post_type();
|
$post_type = get_post_type();
|
||||||
if ( ! empty( $setting['post_type'][ $post_type ] ) ) {
|
if ( isset( $setting['post_type'][ $post_type ] ) && $setting['post_type'][ $post_type ] ) {
|
||||||
/**
|
/**
|
||||||
* Creates display_featured_image_genesis_use_post_type_image filter to check
|
* Creates display_featured_image_genesis_use_post_type_image filter to check
|
||||||
* whether get_post_type array should use the post type image.
|
* whether get_post_type array should use the post type image.
|
||||||
|
|||||||
@@ -208,7 +208,11 @@ class Display_Featured_Image_Genesis_Settings_Define extends Display_Featured_Im
|
|||||||
|
|
||||||
$post_types = $this->get_post_types();
|
$post_types = $this->get_post_types();
|
||||||
if ( $post_types ) {
|
if ( $post_types ) {
|
||||||
unset( $post_types['post'] );
|
$show_on_front = get_option( 'show_on_front' );
|
||||||
|
$posts_page = get_option( 'page_for_posts' );
|
||||||
|
if ( 'page' === $show_on_front && $posts_page ) {
|
||||||
|
unset( $post_types['post'] );
|
||||||
|
}
|
||||||
foreach ( $post_types as $post_type => $label ) {
|
foreach ( $post_types as $post_type => $label ) {
|
||||||
$fields[] = array(
|
$fields[] = array(
|
||||||
'id' => 'post_types][' . esc_attr( $post_type ),
|
'id' => 'post_types][' . esc_attr( $post_type ),
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class Display_Featured_Image_Genesis_Settings_Validate extends Display_Featured_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ( $this->get_content_types() as $post_type ) {
|
foreach ( $this->get_content_types_built_in() as $post_type ) {
|
||||||
|
|
||||||
$object = get_post_type_object( $post_type );
|
$object = get_post_type_object( $post_type );
|
||||||
$old_value = isset( $this->setting['post_type'][ $object->name ] ) ? $this->setting['post_type'][ $object->name ] : '';
|
$old_value = isset( $this->setting['post_type'][ $object->name ] ) ? $this->setting['post_type'][ $object->name ] : '';
|
||||||
|
|||||||
Reference in New Issue
Block a user