74701e02 by Jeremy Groot

reverted back to old

1 parent f9bd478c
......@@ -89,49 +89,18 @@ function resources_list($atts){
'posts_per_page' => -1,
'paged' => 1,
'post_status' => 'any',
// 'order' => 'DESC',
// 'orderby' => 'rand',
'order' => 'DESC',
'orderby' => 'rand',
'tax_query' => ['relation' => 'OR', $tax_queries],
);
$custom_query = get_posts($custom_args);
usort($custom_query, function($a, $b) {
$adate = strtotime(get_post_meta($a->ID, 'searchwp_content_pdf_metadata', true)['CreationDate']);
$bdate = strtotime(get_post_meta($b->ID, 'searchwp_content_pdf_metadata', true)['CreationDate']);
if(empty($adate)) {
$adate = strtotime($a->post_date);
}
if(empty($bdate)) {
$bdate = strtotime($b->post_date);
}
// if($a->ID == 69064) {
// var_dump($adate);exit;
// }
if($adate < $bdate) {
return 1;
} else if($adate > $bdate) {
return -1;
}
});
$custom_query = new \WP_Query($custom_args);
$favs = get_user_meta(get_current_user_id(),'fav_resources',true);
ob_start();
if (!empty($custom_query)):
if ($custom_query->have_posts()):
?>
<div class="course-list resources hidden">
<div class='quicksearch-wrapper'>
......@@ -182,16 +151,15 @@ function resources_list($atts){
<table id="resources" class='hidden'>
<thead><tr><th class="hidden"></th><th></th><th class="hidden"></th></tr></thead>
<tbody>
<?php foreach ($custom_query as $post):
<?php while ($custom_query->have_posts()):
$custom_query->the_post();
if(is_array($favs)) {
$is_fav = in_array($post->ID, $favs);
$is_fav = in_array(get_the_ID(), $favs);
} else {
$is_fav = false;
}
echo resources($post->ID, $organized_term_filter, $is_fav);
endforeach; ?>
echo resources(get_the_ID(), $organized_term_filter, $is_fav);
endwhile; ?>
</tbody>
</table>
......@@ -274,11 +242,6 @@ function resources($id, $taxes, $is_fav = false){
$updated_at = get_field('updated_at', $post->ID);
$is_new = get_field('is_new', $post->ID);
$post_date = strtotime(get_post_meta($id, 'searchwp_content_pdf_metadata', true)['CreationDate']);
if(empty($post_date)) {
$post_date = get_post_time('U',false, $id );
}
$categories = [];
foreach($taxes as $tax => $val) {
$terms = get_the_terms( $id, $tax );
......@@ -318,7 +281,7 @@ function resources($id, $taxes, $is_fav = false){
<?php } ?>
</td>
<td class="hidden"> <?php echo $cat; ?></td>
<td class="hidden"><?php echo $post_date; ?></td>
<td class="hidden"><?php echo get_post_time('U',false, $id ); ?></td>
</tr>
<?php
$output = ob_get_clean();
......