Title: Query posts from URL String
Last modified: August 20, 2016

---

# Query posts from URL String

 *  [cmsdevelopers](https://wordpress.org/support/users/cmsdevelopers/)
 * (@cmsdevelopers)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/query-posts-from-url-string/)
 * Hello,
 * I want to query posts based on post date & category. The code I am using to display
   results
 *     ```
       <?php query_posts( 'category-name=Events&month='.$month.'&day='.$day ); ?>
         <?php while (have_posts()) : the_post(); ?>
         <ul>
       	  <li><a href="<? the_permalink(); ?>"><? the_title(); ?></a>
             <small><?php the_date('Y-m-d'); ?></small>
             </li>
         </ul>
         <?php endwhile;?>
       ```
   
 * I would like to pass the values of month and day from a url string as follows:
   `
   <a href="<? bloginfo('home'); ?>/event-results?month=<?php echo $calendar->month()?
   >&day=<? echo $number; ?>&year=<?php echo $calendar->year ?>"><?php echo $number?
   >`
 * The way I have this setup, is as follows:
    1) I created a custom template that
   contains the above query – I assigned this template to a page named: Event Results
 * 2) On another custom template, I am generating a calendar ( see live page: [http://www.htmlupdates.com/demo/chuck/event-calendar/](http://www.htmlupdates.com/demo/chuck/event-calendar/))
   Each date generates a unique url ( day updates from loop – $number.
 * 3) When visitor clicks the link a listing of all posts having the publish date
   equal to the date selected
 * Currently – the event-results page returns an error and is not accepting the 
   sent string. In-fact, it seems that when visiting event-results – it is not even
   using the set page template ( which would make it impossible to display the query
   in event-results.php custom template ).
 * This url works:
    [http://www.htmlupdates.com/demo/chuck/event-results/?month=October&day=25&year=2011](http://www.htmlupdates.com/demo/chuck/event-results/?month=October&day=25&year=2011)(
   see explanation [http://www.screencast.com/t/EDapgLAs1](http://www.screencast.com/t/EDapgLAs1))
 * This url works:
    [http://www.htmlupdates.com/demo/chuck/event-results/](http://www.htmlupdates.com/demo/chuck/event-results/)(
   no url string – link directly to event-results page )
 * This url DO NOT work:
    [http://www.htmlupdates.com/demo/chuck/event-results?month=October&day=27&year=2011](http://www.htmlupdates.com/demo/chuck/event-results?month=October&day=27&year=2011)(
   Note: Although there is no post set for that day, there should still show the
   echo I have on the custom template to display url string data )
 * Any help is very much appreciated

The topic ‘Query posts from URL String’ is closed to new replies.

## Tags

 * [calendar](https://wordpress.org/support/topic-tag/calendar/)
 * [url string](https://wordpress.org/support/topic-tag/url-string/)

 * 0 replies
 * 1 participant
 * Last reply from: [cmsdevelopers](https://wordpress.org/support/users/cmsdevelopers/)
 * Last activity: [14 years, 6 months ago](https://wordpress.org/support/topic/query-posts-from-url-string/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
