ポイントというか
ハマった点は
get post の
cat =>
ではタームID?
ゲットがテゴリーでとった id では
だめだめで
けっか
タックスクエリーをしなきゃいかんかった
<div class="disign_cate_box_all">
<?php
$cat_tax= 'd_cate_jirei';
$filed ='d_jirei_cat_img';
$args = array(
'type' => 'post',
'child_of' => 0,
'parent' => 0,//0で親かてのみ ''で子もでる
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 0,
'hierarchical' => 1,
'exclude' => '',
'include' => '',
'number' => '',
'taxonomy' => $cat_tax,
'pad_counts' => false ,
'exclude' => '321,322'
);
$categories = get_categories($args);
//$categories = get_categories('parent=0'); 親カテゴリーのみ
foreach($categories as $category) :
$cat_id = $category->cat_ID;
$post_id = $cat_tax.'_'.$cat_id;
$catimg = get_field($filed,$post_id);
$img = wp_get_attachment_image_src($catimg,W214_142);
$disp = get_field('d_jirei_cat_disp',$post_id);
$catekakaku1 = get_field('catekakaku1',$post_id);
$catekakaku2 = get_field('catekakaku2',$post_id);
$catekakaku3 = get_field('catekakaku3',$post_id);
?>
<div class="disign_cate_box">
<h3 class="disign_cate_box_title"><i class="icon-quote-left"></i><?php echo $category->cat_name; ?></h3>
<div style="position:relative; margin-bottom:20px;">
<div class="disign_cate_box_img_box">
<div class="dcent">
<?php
// 1ヶ月以内に投稿された記事を取得して、あればNEWを出力する
$three_month_ago = date('Y-m-d 0:0:0', strtotime('-1 month'));//何ヶ月か?
$cat_current = $category->slug; //現在のカテゴリID
$mydata = get_posts(
array( 'post_type' => 'd_jirei',
'date_query' => array(
array(
'after' => $three_month_ago, //何ヶ月か
'inclusive' => true
),
),
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => $cat_tax,
'field' => 'slug',
'terms' => $cat_current,
//'operator'=>'NOT IN'
),
),
)
);
?>
<?php
if( !empty( $mydata ) ) {
echo '<div class="new_icon"><img src="/img/new_icon/rainbow1.gif" width="31" height="12" alt="愛知県春日井市ホームページ制作NEW記事"></div>';
?>
<?php
}
wp_reset_postdata();
?>
<a href="/デザイン事例カテゴリ/<?php echo $category->category_nicename; ?>" style="background-color:#FFF">
<img src="<?php if($img):
echo $img[0];
else:
echo '/img/no_photo_214_142.jpg';
endif;
?>" alt="<?php echo $category->cat_name; ?>" /></a></div></div>
<?php
echo $disp
?>
<div style="clear:both;"></div>
<a href="/デザイン事例カテゴリ/<?php echo $category->category_nicename; ?>" class="d_cate_tuduki mailform_bottan">制作実績をみる</a>
</div>
<?php if($catekakaku1):?>
<table><caption>料金の目安</caption><tr><td><?php echo $catekakaku1; ?></td><td><?php echo $catekakaku2; ?></td></tr></table>
<?php endif; ?>
<div style="font-size:80%; padding:12px;">
<?php echo$catekakaku3; ?>
</div>
</div>
<?php endforeach; ?>
<div style="clear:both;"></div>
</div>
</div class="jirei_box_all">
http://notebook.yamamotohiroyuki.com/wordpress/2012/08/15/%E3%81%A1%E3%82%87%E3%81%84%E3%81%A1%E3%82%87%E3%81%84%E5%BF%98%E3%82%8C%E3%82%8B%E3%80%8Ewp_query%E3%80%8F%E3%81%AE%E4%BD%BF%E3%81%84%E6%96%B9/
<?php $args = array( 'cat' => 1, 'posts_per_page' => 5 ); $the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); endwhile; //ここにループするテンプレート endif; wp_reset_postdata(); ?>
http://www.tam-tam.co.jp/tipsnote/cms/post6697.html
<?php
// 2015年9月10日から、2015年10月10日までに投稿された記事を取得して、タイトルを出力する
$mydata = get_posts( array(
'posts_per_page' => -1,
'date_query' => array(
array(
'after' => array(
'year' => 2015,
'month' => 9,
'day' => 10,
),
'before' => array(
'year' => 2015,
'month' => 10,
'day' => 10,
),
'inclusive' => true,
),
),
) );
if( !empty( $mydata ) ) {
foreach( $mydata as $post ) {
setup_postdata( $post );
?>
<h1><?php the_title(); ?></h1>
<?php
}
}
?>
このへんとかは カテゴリ で ポストだったでよかったんだな
何ヶ月いないは
これ参考
http://bugpixel.net/output/web/date_query-wordpress/
<?php
$cats = get_the_category();
$cat = $cats[0];
$cat_current = $cat->cat_ID; //現在のカテゴリID
?>
<?php
$three_month_ago = date('Y-m-d 0:0:0', strtotime('-3 month'));
$mydata = get_posts(array(
'category' => $cat_current,
'date_query' => array(
array(
'after' => $three_month_ago, //3ヶ月
'inclusive' => true
),
)
));
?>
<ul class="link">
<?php
if( !empty( $mydata ) ) {
foreach( $mydata as $post ) {
setup_postdata( $post );
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php
}
}
wp_reset_postdata();
?>
</ul>