うさぎのイラスト

ネットアンサー55備忘録

web技術を書いていきます

phpの中にhtml

-2016年02月04日- 基礎kiso
			  <div class="slide front_result_box"><a href="<?php the_permalink(); ?>">
				<?php ACF_img('メイン画像','w312'); ?>
				<div class="front_result_content">
					<h3><?php the_field('topタイトル'); ?></h3>					
						<?php  //対談の最初のタイトルのみを抽出
					  	$count = 1;
						if( have_rows('対談') ):
							while ( have_rows('対談') ) : the_row();
					  			if($count == 1){
					  				 $first_taidan = get_sub_field('タイトル');
									 $first_taidan = strip_tags($first_taidan);
									 if(mb_strlen($first_taidan) > 30){ //日本語の文字列をカウントしている30文字
					  					echo "<p>". mb_substr($first_taidan, 0, 30),"...</p>";
									 }else{
					  					echo "<p>".$first_taidan."</p>";
									 }
					  				 $first_taidan="";
					  			}
					  			$count++;
							endwhile;
						else :
						endif;
						?>
				</div><!-- / .front_result_content -->			  
			  </a></div><!-- / .slide front_result_box -->