Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Im loading post into a content area via ajax but the latest post is the only one that loads, any one encounter this and manage to fixed it, if so please enlighten me.

   <div class="content">    

<?php $args = array('posts_per_page' => 1); query_posts($args);?>
<?php while ( have_posts() ): the_post(); ?>

    <div id="inner">
        <h2 class="title">
            <?php the_title(); ?>
        </h2>
        <?php the_post_thumbnail(array(150, 150, true)); ?>
        <?php the_content(); ?>  
    </div>



      <div class="clear"></div>

      <?php endwhile; ?>
       <?php wp_reset_query(); ?>

    </div>

its not my ajax script because I get the same result every time, and yes single.php is present but im not using it in anyway.

The javascript

var $mainContent = jQuery(".content"),
            siteUrl = "http://" + top.location.host.toString(),
            url = '';

     jQuery(document).delegate("a[href^='"+siteUrl+"']:not([href*=/wp-admin/]):not([href*=/wp-login.php]):not([href$=/feed/])", "click", function() {
        location.hash = this.pathname;
        return false;
    });



        jQuery(window).bind('hashchange',  function(){
            url = window.location.hash.substring(1); 

            if (!url) {
                return;
            } 

            url = url + " #inner"; 

            $mainContent.slideUp('slow').load(url, function() {
                $mainContent.slideDown('slow');
            });
        });


    jQuery(window).trigger('hashchange');

The links to load for ajax

<!--Slide -->
            <div id="slider" class="clearfix">

                  <ul id="roundabout" class="clearfix">

                        <?php while (have_posts()): the_post(); ?>

                           <li><a href="<?php the_permalink();?>"><?php the_post_thumbnail(array(150, 150, true));?></a></li>

                        <?php endwhile; ?>

                      </ul>

                    <a id="left" href="#">Left</a>
                    <a id="right" href="#">Right</a>

            </div>
        <!-- End #slider -->
share|improve this question
    
How are you using ajax, could you post your code please? From the above you are querying for the last post and then displaying it. –  Stephen Harris Feb 25 '12 at 17:50
    
that could be the problem, how would i know if I am. –  Jermaine Hercules Feb 25 '12 at 19:06

1 Answer 1

up vote 1 down vote accepted

OK, so you're not using AJAX (you didn't share any Javascript here, so I may be confused as to what I'm looking at) but this line:

<?php $args = array('posts_per_page' => 1); query_posts($args);?>

indicates you are setting the number of posts to be displayed to just 1, hence the "posts_per_page" value being set to 1. To increase the number of posts display, push that number up to 10 or 20 or whatever you need.

share|improve this answer
    
I only want one post to show at a time, Its a one page website with load post link from a carousel. –  Jermaine Hercules Feb 25 '12 at 18:34
    
I manage to fix it thanks chris. I change the dashboard reading setting post per page to 1, and removed query post from the main loop. :) –  Jermaine Hercules Feb 26 '12 at 1:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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