Title: WPDB loop fix
Last modified: October 30, 2018

---

# WPDB loop fix

 *  [modeman](https://wordpress.org/support/users/modeman/)
 * (@modeman)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/wpdb-loop-fix/)
 * Hello, i have this post loop code:
 * [code link](https://pastecode.xyz/view/5aa2793a)
 * And i want to correctly delete the setting “t1” (price meta), maybe can you help
   me with correcting this code 🙂

Viewing 1 replies (of 1 total)

 *  [cleancoded](https://wordpress.org/support/users/cleancoded/)
 * (@cleancoded)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/wpdb-loop-fix/#post-10830313)
 * On line 6, remove this:
 * `t1.meta_value as price,`
 * On line 18, change this:
 * `{$table_prefix}posts.ID ORDER BY if(prior = '' or prior is null,1,0), prior 
   DESC, if(date = '' or date is null,1,0), date ASC, if(price = '' or price is 
   null,1,0), price ASC,`
 * to
 * `{$table_prefix}posts.ID ORDER BY if(prior = '' or prior is null,1,0), prior 
   DESC, if(date = '' or date is null,1,0), date ASC,`
 * I also replied on your pastecode link.

Viewing 1 replies (of 1 total)

The topic ‘WPDB loop fix’ is closed to new replies.

## Tags

 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [wpdb](https://wordpress.org/support/topic-tag/wpdb/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 1 reply
 * 2 participants
 * Last reply from: [cleancoded](https://wordpress.org/support/users/cleancoded/)
 * Last activity: [7 years, 5 months ago](https://wordpress.org/support/topic/wpdb-loop-fix/#post-10830313)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
