Disable featured image on all pages

Disable featured image on all pages

Astra has a filter astra_featured_image_enabled which can be used to programmatically enable or disable the featured image.

Here is an example snippet that shows how you can disable the featured image on all the pages by default.

/**
* Disable featured images for pages.
* Set the featured image to false if current post type is 'page'
*
* @param boolean $status True - Enable featured image; False - Disable featured image
* @return boolean Featured image status based on the
*/
function disable_feattured_image_for_posts( $status ) {

// disable featured image for pages.
if ( 'page' == get_post_type() ) {
$status = false;
}

return $status;
}

add_filter( 'astra_featured_image_enabled', 'disable_feattured_image_for_posts' );

Note:

Add the above code into the child theme』s functions.php file.

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注