WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] paging custom queries (2 posts)

  1. freshifreshy
    Member
    Posted 6 years ago #

    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!

  2. RickyV
    Member
    Posted 5 years ago #

    Hi did you find a way to do this?. I'm trying to do the same. Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic