|
|
@@ -156,8 +156,7 @@ class Make_Sort_By extends WP_REST_Controller {
|
|
156
|
156
|
public function by_episode( $request ) {
|
|
157
|
157
|
$q = new WP_Query($this->make_args($request, null));
|
|
158
|
158
|
global $wpdb;
|
|
159
|
|
-
|
|
160
|
|
- $type = $q->query['post_type'] . 's';
|
|
|
159
|
+ $type = $q->query['post_type'];
|
|
161
|
160
|
|
|
162
|
161
|
// TODO: optimize this query
|
|
163
|
162
|
$items = $wpdb->get_results($wpdb->prepare(
|
|
|
@@ -170,7 +169,7 @@ class Make_Sort_By extends WP_REST_Controller {
|
|
170
|
169
|
WHERE wp_posts.post_type = %s AND wp_posts.post_status = 'publish'
|
|
171
|
170
|
AND (wp_p2p.p2p_type = %s OR wp_p2p.p2p_type = %s)
|
|
172
|
171
|
ORDER BY header.post_date DESC, related_episode, wp_posts.post_date DESC",
|
|
173
|
|
- trim($type, 's'), $type . '_to_episodes' , 'episodes_to_' . $type,
|
|
|
172
|
+ $type, $type . 's_to_episodes' , 'episodes_to_' . $type . 's',
|
|
174
|
173
|
));
|
|
175
|
174
|
wp_reset_postdata();
|
|
176
|
175
|
|