WordPress.org

Ready to get started?Download WordPress

Forums

Show post from same category same month (1 post)

  1. Kawsar
    Member
    Posted 1 year ago #

    I need to show something like this in the single template if the post is magazine category show all the post that was published in same month from only that category. I tried the following.

    <?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(); ?>

    Thanks in advance

Topic Closed

This topic has been closed to new replies.

About this Topic