0

My archive.php

<?php wp_get_archives( array( 'type' => 'monthly', 'limit' => 12, 'show_post_count' => 1 ) ); ?><br/>

My date.php

$date1 = get_query_var('date');

              // The Query
              query_posts( array ( 'date' => $date1, 'posts_per_page' => -1 ) );

              // The Loop
             while ( have_posts() ) : the_post(); ?>

                <li>
                <?php the_time( get_option( 'date_format' ) ); ?> <br/>
                <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
              </li></br>

              <?php endwhile;

              // Reset Query
              wp_reset_query();?>

but it show all the posts form the blog. how can I edit it to show the post from the proper year and month when some one click the link generated by arhive.php?

  • How are these two files interlinked ? Can you please explain it more. – Subharanjan Dec 12 '13 at 11:36
  • these files are placed in to my theme folder. my theme folder has index.php, style.css, archive.php, category.php, author.php and date.php. so when I click links from www.mydomain.com/blogarchive that will be redirected to the proper page. isn't it? eg: if I click archive by author then it will be redirected to author.php. its a default action by wordpress. am i right? – Riffaz Starr Dec 12 '13 at 11:56
  • get rid of the call to query_posts and just output the default query. – Milo Dec 12 '13 at 16:17
  • @Milo could you please explain bit more? can I get what I want as I mentioned above if I use the default query instead of query_post? – Riffaz Starr Dec 13 '13 at 4:18
  • now on my date.php I have the following codes only. while ( have_posts() ) : the_post(); ?> <li><?php the_time( get_option( 'date_format' ) ); ?> <br/> <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li></br> <?php endwhile; wp_reset_query();?>' when I click **Dec, 2011** on www.mydomain.com/blog/archive` then the URL becomes www.mydomain.com/blog/2013/12 that's currect. but it shows only three posts. – Riffaz Starr Dec 13 '13 at 5:39
0

It's working very fine after I made some changes / adding on two php files function.php and date.php

function.php

function wpa_date_posts_per_page( $query ) {
    if ( !is_admin()
        && $query->is_date()
        && $query->is_main_query() ) {
            $query->set( 'posts_per_page', -1 );
    }
}
add_action( 'pre_get_posts', 'wpa_date_posts_per_page' );

date.php

<?php get_header(); 
            while (have_posts()) : the_post(); 
            echo the_title() . '<br/><br/>';
            endwhile;
            wp_reset_query();
get_footer();?>

archive.php

<?php wp_get_archives( array( 'type' => 'monthly', 'limit' => 12, 'show_post_count' => 1 ) ); ?><br/>

very special thanks to @milo

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.