0

単一のテンプレートでこのようなものを表示する必要があります。投稿が雑誌のカテゴリにある場合、そのカテゴリから同じ月に発行されたすべての投稿を表示します。私は次のことを試しました:

    <?php
    $current_year = get_the_date('j',$the_post->post_parent);
    $current_month = get_the_date('F',$the_post->post_parent);
    query_posts($query_string . '&cat=1700&order=DESC&year=$current_year&monthnum=$current_month');
    ?>

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <li> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile; endif; ?>

<?php wp_reset_query(); ?>

前もって感謝します

4

1 に答える 1

0

query_postsはじめに、問題のないIMOの光沢のないものを使用しないでください;)詳細はこちらをご覧ください。

これを試して:

$today = getdate();
$args = array('monthnum' => $today["mon"], 'cat' => 1700, 'order' => 'DESC', 'year' => $today["year"]);
$the_query = new WP_Query( $args );

while ( $the_query->have_posts() ) :
$the_query->the_post();
echo '<li><a href="'.get_the_permalink().'">' . get_the_title() . '</a></li>';
endwhile;

wp_reset_postdata();
于 2013-03-12T17:48:32.880 に答える