• Resolved Wanderley Souza

    (@wanderley-souza)


    I can list all the posts by a specific date?

    Below an idea to understand.

    <!– Loop –>
    <?php if(have_posts()) : while(have_posts()) : the_post(); get_the_time(‘d-m-Y’) == ’29-10-2015′; ?>

    Where get_the_time(‘d-m-Y’) would receive the date of the post (post_date) and ’29-10-2015′ would be my condition to list only posts this day.

    Obs .: Align bold code above does not work very least it is logical (rsr) … it’s just to represent what I need.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi Wanderley Souza,
    Using this code and define your date for post listing.

    <?php
    
    // Setup arguments.
    $args = array(
        // Day (1 - 31).
        'day' => date( 'j' ),
        // Month (1 - 12).
        'monthnum' => date( 'n' ),
        // Year (minus 1).
        'year' => date( 'Y' ) - 1,
        // Show no of post -1 to all
        'posts_per_page' => 10
    );
    
    // Instantiate new query instance.
    $my_query = new WP_Query( $args );
    
    ?>
    Thread Starter Wanderley Souza

    (@wanderley-souza)

    Sorry, I’m new to wordpress and can not apply this code. Can you give me more details on how to apply it?

    <?php
        $args = array(
        'day' => '29',
        'monthnum' => '10',
        'year' => '2015',
        'posts_per_page' => -1
    );
        $my_query = new WP_Query( $args );
        if($my_query->have_posts()):
    
        while ( $my_query->have_posts() ) :
            $my_query->the_post();
    ?>
        <h2><a href="<?php echo get_permalink(); ?>"><?php echo get_the_title(); ?></a></h2>
        <?php echo get_the_excerpt(); ?>
    
    <?php
        endwhile;
        endif;
        wp_reset_postdata();
    ?>
    Thread Starter Wanderley Souza

    (@wanderley-souza)

    Perfect. It was exactly what she needed. Many thanks ravipatel for help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘posts by a specific date’ is closed to new replies.