WordPress.org

Support

Support » Plugins and Hacks » Hacks » [Resolved] adding a post limit and pagination to a custom meta query

[Resolved] adding a post limit and pagination to a custom meta query

  • munkeyhouse
    Member

    @munkeyhouse

    need to add a post limit of 15 per page and pagination to this query… thx in advance

    <?php
    
    $querystr = "
    	SELECT wposts.*, ABS(
    REPLACE(SUBSTRING(wpostmeta.meta_value, 2)
    , ',', '')) AS sortby
    	FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
    	WHERE wposts.ID = wpostmeta.post_id
    	AND wpostmeta.meta_key = 'price'
            AND wpostmeta.meta_value != '$TBA'
            AND wpostmeta.meta_value != 'REQUEST $'
            AND ABS(REPLACE(REPLACE(wpostmeta.meta_value, '$', ''), ',', '')) > '150'
            AND ABS(REPLACE(REPLACE(wpostmeta.meta_value, '$', ''), ',', '')) < '500'
    		AND post_status='publish'
            ORDER BY sortby asc
    		";
    $pageposts = $wpdb->get_results($querystr, OBJECT); 
    
    if ($pageposts) : foreach ($pageposts as $post): setup_postdata($post);
    	$my_meta = get_post_meta(get_the_ID(), '_my_meta', TRUE);
    ?>
        <?php get_template_part( 'grid', get_post_format() ); ?>
        <?php endforeach; endif; ?>
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] adding a post limit and pagination to a custom meta query’ is closed to new replies.