WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] paging custom queries

[Resolved] paging custom queries

  • I’m having some trouble figuring out how to page the results of my query. It looks like this:

    <?php
    $querystr = "
    SELECT * FROM $wpdb->posts
    LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id)
    LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)
    LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
    WHERE $wpdb->term_taxonomy.term_id = 5
    AND $wpdb->term_taxonomy.taxonomy = 'category'
    AND $wpdb->posts.post_status = 'publish'
    AND $wpdb->postmeta.meta_key = 'Price'
    ORDER BY ABS(0 + $wpdb->postmeta.meta_key) ASC
    
     ";
    
     $pageposts = $wpdb->get_results($querystr, OBJECT);
    
    ?>
    
     <?php if ($pageposts): ?>
      <?php foreach ($pageposts as $post): ?>
        <?php setup_postdata($post); ?>

    Any light on what I need to include to make paging work would be greatly appreciated.

    Thanks!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] paging custom queries’ is closed to new replies.
Skip to toolbar