Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Commonwell
/
broker-site
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
74701e02
authored
2024-02-02 13:44:24 -0500
by
Jeremy Groot
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
reverted back to old
1 parent
f9bd478c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
47 deletions
wp-content/themes/commonwell-broker/inc/shortcodes-resources.php
wp-content/themes/commonwell-broker/inc/shortcodes-resources.php
View file @
74701e0
...
...
@@ -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
();
...
...
Please
register
or
sign in
to post a comment