I display a random publish loop on the page. Let me put a "refresh" connect to refresh this content from the loop via ajax.

Is possible?

This really is my loop:

            <ul id="content-inner" class="thumb-grid clearfix">
            <?php query_posts('posts_per_page=20&orderby=rand'); ?>
            <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                    <a href="<?php the_permalink(); ?>">
                        <img src="<?php echo $my_image_url = get('thumbnail'); ?>" alt="" />
                        <span class="title"><?php the_title(); ?></span>
                        <span class="feat"><?php $articletags = strip_tags(get_the_tag_list('',', ',''));echo $articletags;?></span>
            <?php endwhile;?>
            <?php endif; ?>
            <?php wp_reset_query(); ?>


Place the random publish code inside a div (should you haven't already), and refresh the items in that div with JQuery...

Something similar to this will work (however i haven't had time for you to test)...

Within the Mind of the page reference JQuery, then use JQuery.Prepared to load the very first random publish (for initial page load):


<script> /*...reference JQuery...*/ </script>
  jQuery(document).ready(function($) {
    $("#randomdiv").html("<?php getRandomPost() ?>");



<div id="randomdiv">[placeholder text]</div>
<a id="refresh" href="#">click</a>

<!-- Then for the REFRESH:
make sure this script occurs AFTER your div (above) -->
    $(function() {
      $("#refresh").click(function(evt) {
         $("#randomdiv").html("<?php getRandomPost() ?>");


So place your entire loop code inside a function known as getRandomPost() (or something like that) and put it inside your wordpress "functions.php" file..., then just call "$("#randomdiv").html("")" within the mind of the page for initial load, then in your body as I have proven for that refresh...