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 7569637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:12:58+00:00 2026-05-30T15:12:58+00:00

OK here goes, I’m using jQuery ajax to load post from inside a slider.

  • 0

OK here goes, I’m using jQuery ajax to load post from inside a slider. In wordpress dashboard I set the number of post per page to “one”.

The problem I’m having is only the latest post created keeps on being loaded. Also sometimes the inner loop keep on going forever.

I need whatever link from the slider, when clicked, to simply load the post inside the content area I set, Below is all the relevant code.

The slider code

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

<?php  $argss = array(
"showposts" =>20);

query_posts($argss);  ?>


    <?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>

The jQuery ajax code

    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 + " .content"; 

    $mainContent.fadeOut().load(url, function() {
        $mainContent.fadeIn();
    });
});

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

The PHP code

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

    <div class="content">    

        <?php wp_reset_query(); ?>

            <?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>

                <?php endwhile; ?>

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

    </div>

<?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-05-30T15:13:00+00:00Added an answer on May 30, 2026 at 3:13 pm

    take a look at WP_Query in the codex: http://codex.wordpress.org/Class_Reference/WP_Query

    Your ‘loop inside a loop’ wont work as you’ve structured here because there is no second query. Try using WP_Query inside the first main loop to get the posts for your second loop

    <?php while ( have_posts() ): the_post(); ?>
    
    <div class="content">    
    
        <?php
    
        // Second Query
        $the_query = new WP_Query( $args );
    
        // Second Loop
        while ( $the_query->have_posts() ) : $the_query->the_post();
    
        ?>
    
                <div id="inner">
                    <h2 class="title"><?php the_title(); ?></h2>
                    <?php the_post_thumbnail(array(150, 150, true)); ?>
                    <?php the_content(); ?>  
                </div>
    
          <?php endwhile;
    
          // Reset Second Loop Post Data
          wp_reset_postdata(); 
    
          ?>
    
      <div class="clear"></div>
    
    </div>
    
    <?php  endwhile; ?>
    

    This should help solve half of your problem 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First post, so here goes. I'm writing a script that does intelligent search and
Here goes a command object which needs to be populated from a Spring form
Here goes newbie question number 5, but I don't have a teacher.. so.. anyhow
Here goes, second post, first didn't go to well.... I am calling an SP
I'm pretty new to this so here goes... I'm using Visual Studio 05 (C#)
This should be a simple Yes/No answer so here goes. If I set a
this may be a general question on sharing variables but here goes. I'm using
Ok here goes: I have a SELECT drop down option with US state names
Weird to describe but here goes. I have a table with several rows. One
I assume this is pretty easy so here goes; I'm trying to execute these

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.