Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Oct 29th, 2010 | Syntax: PHP | Size: 0.54 KB | Views: 279 | Expires: Never
  1. <?php
  2. /**
  3.  * Public Ajax callback
  4.  * Acess this through a url similar to: /wp-admin/admin-ajax.php?action=my_archive_query&m=201009
  5.  */
  6. function my_archive_query() {
  7.         query_posts( $_GET ); // May need to sanitize first???
  8.         if( have_posts() ) {
  9.                 while ( have_posts() ) {
  10.                         the_post();
  11.                         the_title( '<h2>', '</h2>' );
  12.                         the_content();
  13.                 }
  14.         }
  15.         else {
  16.                 print '<p>No Posts found message.';
  17.         }
  18.         exit;
  19. }
  20. add_action( 'wp_ajax_my_archive_query', 'my_archive_query' );
  21. add_action( 'wp_ajaxnopriv_my_archive_query', 'my_archive_query' );
  22. ?>