Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
MSF
/
msf-climate-hub
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
5fea301d
authored
2023-08-22 20:48:28 -0400
by
Jeff Balicki
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
exclude_in_search_results
Signed-off-by: Jeff <jeff@gotenzing.com>
1 parent
fbd3c19f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
16 deletions
wp-content/themes/msf-child/inc/search-extras.php
wp-content/themes/msf-child/inc/search-extras.php
View file @
5fea301
...
...
@@ -10,24 +10,29 @@ function add_attachment_mime_type( $attachment_id ){
}
function
exclude_from_search
(
$query
)
{
if
(
!
is_admin
()
&&
$query
->
is_main_query
()
&&
is_post_type_archive
(
'shows'
)
)
{
$current_meta
=
$query
->
get
(
'meta_query'
);
$custom_meta
=
array
(
'key'
=>
'exclude_from_search'
,
'type'
=>
'BINARY'
,
'value'
=>
'1'
,
'compare'
=>
'!='
);
$meta_query
=
$current_meta
[]
=
$custom_meta
;
$query
->
set
(
'meta_query'
,
array
(
$meta_query
));
function
exclude_in_search_results
(
$query
)
{
if
(
$query
->
is_main_query
()
&&
$query
->
is_search
()
&&
!
is_admin
()
)
{
$query
->
set
(
'post_type'
,
array
(
'post'
,
'attachment'
,
'pages'
,
'documents'
,
'documents'
)
);
$query
->
set
(
'meta_query'
,
array
(
'relation'
=>
'OR'
,
array
(
'relation'
=>
'AND'
,
array
(
'key'
=>
'exclude_from_search'
,
'value'
=>
'1'
,
'compare'
=>
'!='
,
),
),
)
);
}
}
add_action
(
'pre_get_posts'
,
'exclude_from_search
'
);
}
//add_action( 'pre_get_posts', 'exclude_in_search_results
' );
// apply tags to attachments
...
...
Please
register
or
sign in
to post a comment