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.

I use the below code to display the first 5 results.

<ul class="category_list_view" id="widget_index_upcomming_events_id">
<?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->term_relationships tr join $wpdb->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->postmeta.post_id from $wpdb->postmeta where $wpdb->postmeta.meta_key='st_date' and date_format($wpdb->postmeta.meta_value,'%Y-%m-%d %G:%i:%s') >'".$today."')) ";

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

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

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

<?php 
        endforeach;
 } else {
  echo "<p>".UPCOMING_NOT_FOUND_TEXT."</p>";
 } 
?>
</ul>

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

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

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

Please help..

share|improve this question
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.