Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7974141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:17:22+00:00 2026-06-04T08:17:22+00:00

I just want to List the posts published between two particular dates I found

  • 0

I just want to List the posts published between two particular dates

I found a solution Here http://www.wprecipes.com/wordpress-loop-get-posts-published-between-two-particular-dates

and my code is Here, unfortunately This is not working !!

<?php
          function filter_where($where = '') {
                $where .= " AND post_date >= '2012-05-09' AND post_date <= '2012-05-11'";
                //$where .= " AND post_date > '" . date('Y-m-d', strtotime('-30 days')) . "'";
            return $where;
          }
        add_filter('posts_where', 'filter_where');
        query_posts($query_string);
        ?>
               <?php while (have_posts()) : the_post(); ?>    
                    <h1><?php the_title(); ?></h1>
               <?php endwhile; ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T08:17:23+00:00Added an answer on June 4, 2026 at 8:17 am

    First you shouldn’t be using query_posts() as it will destroy globals and mess up conditionals etc…

    You didn’t mention where this code is running. If it is on a page template for instance you will not get any posts because when pass $query_string into your query you are using the global $wp_query object and it will only query for page post_types.

    I tested your code using new WP_Query instead of query_posts and it worked fine.

    function filter_where( $where = '' ) {
    
    $where .= " AND post_date >= '2012-05-01' AND post_date < '2012-05-14'";
    return $where;
    }
    
    add_filter( 'posts_where', 'filter_where' );
    
    $query = new WP_Query( array( 'post_type' => 'post' ) );
    
        echo '<div id="content" style="color: white!important;">';
        echo '<h1>And here are the posts……</h1>';
        while( $query->have_posts() ) : $query->the_post();
        
        echo '<h2>'. get_the_title() .'</h2>';
        
        
        endwhile;
        echo '</div>';
        
        
    remove_filter( 'posts_where', 'filter_where' );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just want to get the total days in a list of dates. Here
If I just want a sorted list of just dates, integers, or doubles is
I just want to know the difference between List<string> lst = new List() and
I have two categories, visible and hideMe... I want to list all posts in
Semantically, I want an itemized list, but visually I just want some space. How
I just want get a 2 dimension array of List in c#. In my
AH! I have a list of strings... and i just want to remove an
Rather than just grabbing the user's friends' emails, I want to show their list
When a list of posts are generated, I want a logged in user to
I have model Post and collection Posts. And want to make form with list

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.