カスタムポストの新着情報
<h3 class="widgettitle">施工例 NEW !!</h3> <?php $args = array( 'posts_per_page' => 3, 'post_type' => 'jirei_new', //カスタム投稿名 ); ?> <?php query_posts( $args ); if ( have_posts () ) : while ( have_posts() ) : the_post(); ?> <div class="popular_one"> <div class="popular_sam"> <?php $i = 0; $kiji = 1;//この回数でフォーチ終わる。 $fields = $cfs->get('jirei_imgs'); foreach ($fields as $field) : if($i >= $kiji)://siが3よりおおきくなったら break;//ループおわり else://それまではこれで出力 ?> <?php $title= get_the_title(); $attachment_id = $field['jirei_img']; $sample_photo = wp_get_attachment_image($attachment_id,'jirei_small',0,array('alt'=>$title,'title'=>$title));?> <a href="<?php the_permalink(); ?>"> <?php echo $sample_photo; ?> </a> <?php $i++;//多分繰り返すごとに$iに数値が1つづ増える endif; endforeach; ?> </div> <h4><div class="popular_title"><a href="<?php the_permalink(); ?>"> <?php the_title(); ?></a></div></h4> <div class="popular_date" style="padding-top:5px;"> <p><?php get_trim_str(array('str'=>get_post_meta($post->ID,"jirei_disp",true), 'len'=>100)); ?></p> </div> </div> <?php endwhile; endif; ?> <!-----------------リセットクエリ---------> <?php wp_reset_query(); ?>
新着ブログ
<h3 class="widgettitle">新着ブログ</h3> <?php $args = array( 'posts_per_page' => 3, 'cat' => 4, ); ?> <?php query_posts( $args ); if ( have_posts () ) : while ( have_posts() ) : the_post(); ?> <div class="popular_one"> <div class="popular_sam"><a href="<?php the_permalink(); ?>"> <?php $title= get_the_title(); the_post_thumbnail('side_new_post_sam', array('class' => 'blog_sam_img','alt' =>$title, 'title' => $title) ); ?> </a></div> <div class="popular_date"><?php the_time('Y/m/d'); ?></div> <div class="popular_title"><p><a href="<?php the_permalink(); ?>"> <?php the_title(); ?></a></p></div> </div> <?php endwhile; endif; ?> <!-----------------リセットクエリ---------> <?php wp_reset_query(); ?>
新着 サムネイルなし
<h3 class="widgettitle">Information</h3> <?php $args = array( 'posts_per_page' => 3, 'cat' => 5, ); ?> <?php query_posts( $args ); if ( have_posts () ) : while ( have_posts() ) : the_post(); ?> <div class="popular_one"> <div class="popular_sam"><a href="<?php the_permalink(); ?>"> <?php $title= get_the_title(); the_post_thumbnail('side_new_post_sam', array('class' => 'blog_sam_img','alt' =>$title, 'title' => $title) ); ?> </a></div> <div class="popular_date"><?php the_time('Y/m/d'); ?></div> <div class="popular_title"><p><a href="<?php the_permalink(); ?>"> <?php the_title(); ?></a></p></div> </div> <?php endwhile; endif; ?> <!-----------------リセットクエリ---------> <?php wp_reset_query(); ?>
css
/*-----------------------------------------------------ウィジェット用-----------------------------------------------------*/ .widgettitle{ font-size: 12px; margin-top: 20px; margin-bottom: 30px; line-height: 44px; height: 40px; background-color: #595959; -webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px; -moz-border-radius-topleft: 5px; -moz-border-radius-topright: 5px; -moz-border-radius-bottomright: 5px; -moz-border-radius-bottomleft: 5px; color: #FFF; padding-left: 15px; border-left-width: 4px; border-left-style: solid; border-left-color: #e50012; } .widget{ list-style-type: none; } /*-----------------------------------------------------wp popular postプラグイン用-----------------------------------------------------*/ .popular-posts{} .popular_one{ margin-bottom: 8px; padding-bottom: 8px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #CCC; clear: both; overflow: hidden; } .popular_sam{ float: left; } .popular_sam img{ float: left; background-color: #FFF; padding: 1px; border: 1px solid #CCC; margin-right: 12px; } .popular_date{ font-size: 10px; } .popular_title{ font-size: 12px; } .wpp-views{ color: #FF7737; }