• hey, im having a problem. Im not very good in php and need to add a pagination for this query (it shows upcoming events..).

    <?php // Build a custom query to get posts from future dates.
    					$querystr = "
       	 				SELECT wposts.*
        				FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
       	 				WHERE wposts.ID = wpostmeta.post_id
        				AND wpostmeta.meta_key = 'Date'
    					AND STR_TO_DATE(wpostmeta.meta_value,'%m/%d/%Y') >= CURDATE()
    					AND wposts.post_status = 'publish'
    					AND wposts.post_type = 'post'
    					ORDER BY STR_TO_DATE(wpostmeta.meta_value,'%m/%d/%Y') ASC
    					LIMIT 20
    					";
    					$events = $wpdb->get_results($querystr, OBJECT);
    					if ($events):
    					global $post;
     					foreach ($events as $post):
     					setup_postdata($post); ?>
    						<div class="post-thumb-title">
     							<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail(array(160,281));?>
     								<p class="thumb-date"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php echo get_post_meta($post->ID, 'Date', true); ?></p><br>
     								<p class="thumb-title"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></p>
    							</a>
    						</div>
    				<?php endforeach;
    				else : ?><li>Sorry, no events coming up.</li>
    				<?php endif; ?>

The topic ‘pagination for custom select query’ is closed to new replies.