@charset "UTF-8";

/*!
Theme Name: Cocoon Child
Description: Cocoon専用の子テーマ
Theme URI: https://wp-cocoon.com/
Author: わいひら
Author URI: https://nelog.jp/
Template:   cocoon-master
Version:    1.1.3
*/

/************************************
** 子テーマ用のスタイルを書く
************************************/
/*必要ならばここにコードを書く*/

/************************************
** レスポンシブデザイン用のメディアクエリ
************************************/
/*1023px以下*/
@media screen and (max-width: 1023px){
  /*必要ならばここにコードを書く*/
}

/*834px以下*/
@media screen and (max-width: 834px){
  /*必要ならばここにコードを書く*/
}

/*480px以下*/
@media screen and (max-width: 480px){
  /*必要ならばここにコードを書く*/
}

function default_category_eyecatch() {
	
global $post;
	$user_eyecatch = has_post_thumbnail($post->ID);            
	if (!$user_eyecatch)  {
		$preset_image = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" );
		if ($preset_image) {				  
			foreach ($preset_image as $attachment_id => $attachment) {
			set_post_thumbnail($post->ID, $attachment);
			}
		}
		else if ( in_category('1') ) {
			set_post_thumbnail($post->ID, '18');
		}
		else if ( in_category('3') ) {
			set_post_thumbnail($post->ID, '21644');
		}
		else if ( in_category('7') ) {
			set_post_thumbnail($post->ID, '21661');
		}
		else if ( in_category('8') ) {
			set_post_thumbnail($post->ID, '21641');
		}
		else if ( in_category('9') ) {
			set_post_thumbnail($post->ID, '21660');
		}
		else if ( in_category('10') ) {
			set_post_thumbnail($post->ID, '21641');
		}
		else {
			set_post_thumbnail($post->ID, '21654');
			wp_reset_postdata();
		}					   
	}                       
}
add_action('the_post', 'default_category_eyecatch');