Load the next posts ajax
<p>I use the below code to display the first 5 results.</p>

<pre><code>&lt;ul class="category_list_view" id="widget_index_upcomming_events_id"&gt;
&lt;?php
global $post,$wpdb;
$post_number = 5;
$category1 = $category;
$today = date('Y-m-d G:i:s');
if($category) {
 $category = "'".str_replace(",","','",$category)."'";
 $where .= "and p.ID in (select tr.object_id from $wpdb-&gt;term_relationships tr join $wpdb-&gt;term_taxonomy t on t.term_taxonomy_id=tr.term_taxonomy_id where t.term_id in ($category))";
}
$today = date('Y-m-d G:i:s');
@$where .= " AND (p.ID in (select $wpdb-&gt;postmeta.post_id from $wpdb-&gt;postmeta where $wpdb-&gt;postmeta.meta_key='st_date' and date_format($wpdb-&gt;postmeta.meta_value,'%Y-%m-%d %G:%i:%s') &gt;'".$today."')) ";

$sql = "select p.* from $wpdb-&gt;posts p where p.post_type='".CUSTOM_POST_TYPE1."' and p.post_status='publish' $where order by $orderby limit $post_number";

$latest_menus = $wpdb-&gt;get_results($sql);
 if($latest_menus) {

    foreach($latest_menus as $post) :
    setup_postdata($post);
?&gt;
    &lt;li&gt;
    &lt;h3&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h3&gt;
        &lt;?php echo get_post_meta($post-&gt;ID,'address',true); ?&gt;
    &lt;/li&gt;

&lt;?php 
        endforeach;
 } else {
  echo "&lt;p&gt;".UPCOMING_NOT_FOUND_TEXT."&lt;/p&gt;";
 } 
?&gt;
&lt;/ul&gt;
</code></pre>

<p>I wanted to display the next 5 results from the last displayed result of the code above using ajax.</p>

<p>Adding <code>&lt;a&gt;Load More&lt;/a&gt;</code> at the end if there is more than 5 results and add <code>No more results</code> if there is only 5 results. Also, when I click the <code>&lt;a&gt;Load More&lt;/a&gt;</code> and there are no more results to display, then replace <code>&lt;a&gt;Load More&lt;/a&gt;</code> with <code>&lt;b&gt;No more results&lt;/b&gt;</code></p>

<p>I don't know how to do ajax with the code above since im not familiar with jquery.</p>

<p>Please help..</p>
