category.phpと同じ見た目で出力される記事を月別で出したいのですがループがうまく機能しません。
ループを使わない状態では出したい月の記事が1記事だけ表示されてます。
urlは下記のように出てます。
ドメイン名/date/2016/10/
宜しくお願い致します。
php
1<?php if ($posts) : foreach ($posts as $post) : start_wp(); ?> 2 3<div class="child_column_article"> 4<div class="child_column_article_left"> 5<?php the_post_thumbnail('full', array('class' => 'column_relative')); ?> 6<?php 7 $days = 7; 8 $today = date_i18n('U'); 9 $entry = get_the_time('U'); 10 $elapsed = date('U',($today - $entry)) / 86400; 11 if( $days > $elapsed ){ 12 echo "<img src=\"/wp-content/themes/xxx/shared/images/ico_01.png\" class=\"child_column_absolute\">"; 13 } 14?> 15</div> 16<div class="child_column_article_right"> 17<time><?php the_time('Y/n/d'); ?></time> 18<h2><?php the_title();?></h2> 19<p><?php echo mb_substr(strip_tags($post-> post_content),0,40).'...'; ?></p> 20<div class="child_column_article_more"> 21<a href="<?php the_permalink();?>"> 22<img src="<?php echo get_template_directory_uri(); ?>/shared/images/btn_03.png" alt=""> 23</a> 24</div> 25</div> 26</div> 27 28<?php endforeach; else: ?>
category.phpでのループ
php
1 <?php query_posts('showposts=5&orderby=date&category_name=column'); while(have_posts()) : the_post(); ?> 2<div class="child_column_article"> 3<div class="child_column_article_left"> 4<?php the_post_thumbnail('full', array('class' => 'column_relative')); ?> 5<?php 6 $days = 7; 7 $today = date_i18n('U'); 8 $entry = get_the_time('U'); 9 $elapsed = date('U',($today - $entry)) / 86400; 10 if( $days > $elapsed ){ 11 echo "<img src=\"/wp-content/themes/xxx/shared/images/ico_01.png\" class=\"child_column_absolute\">"; 12 } 13?> 14</div> 15<div class="child_column_article_right"> 16<time><?php the_time('Y/n/d'); ?></time> 17<h2><?php the_title();?></h2> 18<p><?php echo mb_substr(strip_tags($post-> post_content),0,40).'...'; ?></p> 19<div class="child_column_article_more"> 20<a href="<?php the_permalink();?>"> 21<img src="<?php echo get_template_directory_uri(); ?>/shared/images/btn_03.png" alt=""> 22</a> 23</div> 24</div> 25</div> 26 27<?php endwhile;?>
念のためfunction.php
php
1<?php 2remove_action('wp_head', 'wp_generator'); 3remove_action('wp_head', 'rsd_link'); 4remove_action('wp_head', 'wlwmanifest_link'); 5remove_action('wp_head', 'print_emoji_detection_script', 7); 6remove_action('wp_head','wp_shortlink_wp_head', 10, 0 ); 7remove_action('wp_head','adjacent_posts_rel_link_wp_head', 10); 8remove_action('wp_print_styles', 'print_emoji_styles' ); 9remove_action('admin_print_scripts', 'print_emoji_detection_script'); 10remove_action('admin_print_styles', 'print_emoji_styles'); 11 12//自動pタグのキャンセル 13add_action('init', function() { 14 remove_filter('the_excerpt', 'wpautop'); 15 remove_filter('the_content', 'wpautop'); 16}); 17 18add_filter('tiny_mce_before_init', function($init) { 19 $init['wpautop'] = false; 20 $init['apply_source_formatting'] = ture; 21 return $init; 22}); 23 24//アイキャッチの有効化 25add_theme_support('post-thumbnails'); 26 27 28?>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/10/13 18:13 編集