WordPress.org

Support

Support » How-To and Troubleshooting » query_posts function to show the post from a month

query_posts function to show the post from a month

  • 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?

Viewing 1 replies (of 1 total)
  • esmi

    @esmi

    Forum Moderator

    Try using:

    extract(shortcode_atts(array(
    'monthnum' => '',
    'id'=> '1',
    'posts_per_page' => -1
    ), $atts));
Viewing 1 replies (of 1 total)
  • The topic ‘query_posts function to show the post from a month’ is closed to new replies.
Skip to toolbar