• In case any one is interested, here’s a way to require featured images by category using Wypiekacz

    function check_my_custom_post_thumbnail( $check, $post_id, $post_data ) {
      if ( $post_id <= 0 ) {
        return false;
      }
    
      $categories = array(); //categories set by editor
      if (is_array($post_data)) {
        $categories = $post_data['post_category'];
      } elseif (is_object($post_data)) {
        $categories = $post_data->post_category;
      }
    
      $categories_requiring_image = array(4); //array containing IDs of the categories for which you want to require a featured image
    
      if (is_array($categories) && count(array_intersect($categories_requiring_image, array_values($categories)))) {
        $image = get_the_image( array(
                'post_id' => $post_id,
                'attachment' => false,
                'echo' => false,
                ) );
        return !empty($image);
      } else {
        return true;
      }
    }
    add_filter( 'wypiekacz_check_thumbnail', 'check_my_custom_post_thumbnail', 10, 3);

    https://www.ads-software.com/extend/plugins/wypiekacz/

  • The topic ‘[Plugin: WyPiekacz] Require featured image depending on category’ is closed to new replies.