reverted back to old
Showing
1 changed file
with
10 additions
and
47 deletions
| ... | @@ -89,49 +89,18 @@ function resources_list($atts){ | ... | @@ -89,49 +89,18 @@ function resources_list($atts){ |
| 89 | 'posts_per_page' => -1, | 89 | 'posts_per_page' => -1, |
| 90 | 'paged' => 1, | 90 | 'paged' => 1, |
| 91 | 'post_status' => 'any', | 91 | 'post_status' => 'any', |
| 92 | // 'order' => 'DESC', | 92 | 'order' => 'DESC', |
| 93 | // 'orderby' => 'rand', | 93 | 'orderby' => 'rand', |
| 94 | 'tax_query' => ['relation' => 'OR', $tax_queries], | 94 | 'tax_query' => ['relation' => 'OR', $tax_queries], |
| 95 | ); | 95 | ); |
| 96 | 96 | ||
| 97 | $custom_query = get_posts($custom_args); | 97 | $custom_query = new \WP_Query($custom_args); |
| 98 | |||
| 99 | usort($custom_query, function($a, $b) { | ||
| 100 | |||
| 101 | $adate = strtotime(get_post_meta($a->ID, 'searchwp_content_pdf_metadata', true)['CreationDate']); | ||
| 102 | $bdate = strtotime(get_post_meta($b->ID, 'searchwp_content_pdf_metadata', true)['CreationDate']); | ||
| 103 | |||
| 104 | if(empty($adate)) { | ||
| 105 | $adate = strtotime($a->post_date); | ||
| 106 | } | ||
| 107 | |||
| 108 | if(empty($bdate)) { | ||
| 109 | $bdate = strtotime($b->post_date); | ||
| 110 | } | ||
| 111 | |||
| 112 | // if($a->ID == 69064) { | ||
| 113 | // var_dump($adate);exit; | ||
| 114 | // } | ||
| 115 | |||
| 116 | |||
| 117 | |||
| 118 | if($adate < $bdate) { | ||
| 119 | return 1; | ||
| 120 | } else if($adate > $bdate) { | ||
| 121 | return -1; | ||
| 122 | } | ||
| 123 | |||
| 124 | |||
| 125 | }); | ||
| 126 | |||
| 127 | |||
| 128 | |||
| 129 | 98 | ||
| 130 | $favs = get_user_meta(get_current_user_id(),'fav_resources',true); | 99 | $favs = get_user_meta(get_current_user_id(),'fav_resources',true); |
| 131 | 100 | ||
| 132 | ob_start(); | 101 | ob_start(); |
| 133 | 102 | ||
| 134 | if (!empty($custom_query)): | 103 | if ($custom_query->have_posts()): |
| 135 | ?> | 104 | ?> |
| 136 | <div class="course-list resources hidden"> | 105 | <div class="course-list resources hidden"> |
| 137 | <div class='quicksearch-wrapper'> | 106 | <div class='quicksearch-wrapper'> |
| ... | @@ -182,16 +151,15 @@ function resources_list($atts){ | ... | @@ -182,16 +151,15 @@ function resources_list($atts){ |
| 182 | <table id="resources" class='hidden'> | 151 | <table id="resources" class='hidden'> |
| 183 | <thead><tr><th class="hidden"></th><th></th><th class="hidden"></th></tr></thead> | 152 | <thead><tr><th class="hidden"></th><th></th><th class="hidden"></th></tr></thead> |
| 184 | <tbody> | 153 | <tbody> |
| 185 | <?php foreach ($custom_query as $post): | 154 | <?php while ($custom_query->have_posts()): |
| 186 | 155 | $custom_query->the_post(); | |
| 187 | if(is_array($favs)) { | 156 | if(is_array($favs)) { |
| 188 | $is_fav = in_array($post->ID, $favs); | 157 | $is_fav = in_array(get_the_ID(), $favs); |
| 189 | } else { | 158 | } else { |
| 190 | $is_fav = false; | 159 | $is_fav = false; |
| 191 | } | 160 | } |
| 192 | 161 | echo resources(get_the_ID(), $organized_term_filter, $is_fav); | |
| 193 | echo resources($post->ID, $organized_term_filter, $is_fav); | 162 | endwhile; ?> |
| 194 | endforeach; ?> | ||
| 195 | </tbody> | 163 | </tbody> |
| 196 | </table> | 164 | </table> |
| 197 | 165 | ||
| ... | @@ -274,11 +242,6 @@ function resources($id, $taxes, $is_fav = false){ | ... | @@ -274,11 +242,6 @@ function resources($id, $taxes, $is_fav = false){ |
| 274 | $updated_at = get_field('updated_at', $post->ID); | 242 | $updated_at = get_field('updated_at', $post->ID); |
| 275 | $is_new = get_field('is_new', $post->ID); | 243 | $is_new = get_field('is_new', $post->ID); |
| 276 | 244 | ||
| 277 | $post_date = strtotime(get_post_meta($id, 'searchwp_content_pdf_metadata', true)['CreationDate']); | ||
| 278 | if(empty($post_date)) { | ||
| 279 | $post_date = get_post_time('U',false, $id ); | ||
| 280 | } | ||
| 281 | |||
| 282 | $categories = []; | 245 | $categories = []; |
| 283 | foreach($taxes as $tax => $val) { | 246 | foreach($taxes as $tax => $val) { |
| 284 | $terms = get_the_terms( $id, $tax ); | 247 | $terms = get_the_terms( $id, $tax ); |
| ... | @@ -318,7 +281,7 @@ function resources($id, $taxes, $is_fav = false){ | ... | @@ -318,7 +281,7 @@ function resources($id, $taxes, $is_fav = false){ |
| 318 | <?php } ?> | 281 | <?php } ?> |
| 319 | </td> | 282 | </td> |
| 320 | <td class="hidden"> <?php echo $cat; ?></td> | 283 | <td class="hidden"> <?php echo $cat; ?></td> |
| 321 | <td class="hidden"><?php echo $post_date; ?></td> | 284 | <td class="hidden"><?php echo get_post_time('U',false, $id ); ?></td> |
| 322 | </tr> | 285 | </tr> |
| 323 | <?php | 286 | <?php |
| 324 | $output = ob_get_clean(); | 287 | $output = ob_get_clean(); | ... | ... |
-
Please register or sign in to post a comment