WordPress.org

Ready to get started?Download WordPress

Forums

query_posts function to show the post from a month (2 posts)

  1. Tanmaygeek
    Member
    Posted 3 years ago #

    I m using the code

    function mnthly_rndps( $atts ) {
    extract(shortcode_atts(array(
    'monthnum' => '','id'=> '1'
    ), $atts));
    //The Query
    query_posts('monthnum=' . $id . '');
    //The Loop
    if ( have_posts() ) : while ( have_posts() ) : the_post();
    echo    '
    <li><h3><a href="'; echo the_permalink(); echo '">'; echo the_title(); echo '</a></h3></li>
    ';
    endwhile; else:
    endif;
    
    //Reset Query
    wp_reset_query();
    }
    add_shortcode('monthnum', 'mnthly_rndps');

    to create a short code to show the posts from a month.
    and the short code as exxample
    [monthnum id=09]
    to show the posts from the month September.
    But when I paste that short code in my post then it is showing only 12 post from that month. Can

    you tell me the actual problem?

  2. esmi
    Forum Moderator
    Posted 3 years ago #

    Try using:

    extract(shortcode_atts(array(
    'monthnum' => '',
    'id'=> '1',
    'posts_per_page' => -1
    ), $atts));

Topic Closed

This topic has been closed to new replies.

About this Topic