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
a62eece5
authored
2023-08-22 19:14:05 -0400
by
Jeff Balicki
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
exclude_post
Signed-off-by: Jeff <jeff@gotenzing.com>
1 parent
dc345ba2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
94 deletions
wp-content/themes/msf-child/inc/search-extras.php
wp-content/themes/msf-child/inc/search-extras.php
View file @
a62eece
...
...
@@ -10,105 +10,30 @@ function add_attachment_mime_type( $attachment_id ){
}
function
wporg_custom_post_type
()
{
register_post_type
(
'documents'
,
array
(
'labels'
=>
array
(
'name'
=>
__
(
'Documents'
,
'textdomain'
),
'singular_name'
=>
__
(
'Documents'
,
'textdomain'
),
),
'public'
=>
true
,
'has_archive'
=>
true
,
'rewrite'
=>
array
(
'slug'
=>
'documents'
),
// my custom slug
)
);
}
//add_action('init', 'wporg_custom_post_type');
function
exclude_post
(
$query
)
{
if
(
$query
->
is_main_query
()
)
{
function
wptp_add_categories_to_attachments
()
{
register_taxonomy_for_object_type
(
'category'
,
'attachment'
);
// register_taxonomy_for_object_type( 'continent', 'attachment' );
// register_taxonomy_for_object_type( 'country', 'attachment' );
// register_taxonomy_for_object_type( 'region', 'attachment' );
}
//add_action( 'init' , 'wptp_add_categories_to_attachments' );
// apply tags to attachments
function
wptp_add_tags_to_attachments
()
{
register_taxonomy_for_object_type
(
'post_tag'
,
'attachment'
);
}
add_action
(
'init'
,
'wptp_add_tags_to_attachments'
);
$meta_query
=
$query
->
get
(
'meta_query'
)
?
$query
->
get
(
'meta_query'
)
:
array
();
// register new taxonomy which applies to attachments
function
wptp_add_taxonomy
()
{
$labels
=
array
(
'name'
=>
'Continent'
,
'singular_name'
=>
'Continent'
,
'search_items'
=>
'Search Continent'
,
'all_items'
=>
'All Continent'
,
'parent_item'
=>
'Parent Continent'
,
'parent_item_colon'
=>
'Parent Continent:'
,
'edit_item'
=>
'Edit Continent'
,
'update_item'
=>
'Update Continent'
,
'add_new_item'
=>
'Add New Continent'
,
'new_item_name'
=>
'New Continent Name'
,
'menu_name'
=>
'Continent'
,
);
$args
=
array
(
'labels'
=>
$labels
,
'hierarchical'
=>
true
,
'query_var'
=>
'true'
,
'rewrite'
=>
'true'
,
'show_admin_column'
=>
'true'
,
);
register_taxonomy
(
'continent'
,[
'attachment'
,
'documents'
],
$args
);
// append yours
$meta_query
[]
=
array
(
'key'
=>
'exclude_from_search'
,
// please make sure that key is correct
'value'
=>
'1'
,
'compare'
=>
'!='
// you can also try 'NOT EXISTS' comparison
);
$query
->
set
(
'meta_query'
,
$meta_query
);
}
}
add_action
(
'pre_get_posts'
,
'exclude_post'
);
$labels
=
array
(
'name'
=>
'Region'
,
'singular_name'
=>
'Region'
,
'search_items'
=>
'Search Region'
,
'all_items'
=>
'All Region'
,
'parent_item'
=>
'Parent Region'
,
'parent_item_colon'
=>
'Parent Region:'
,
'edit_item'
=>
'Edit Region'
,
'update_item'
=>
'Update Region'
,
'add_new_item'
=>
'Add New Region'
,
'new_item_name'
=>
'New Region Name'
,
'menu_name'
=>
'Region'
,
);
$args
=
array
(
'labels'
=>
$labels
,
'hierarchical'
=>
true
,
'query_var'
=>
'true'
,
'rewrite'
=>
'true'
,
'show_admin_column'
=>
'true'
,
);
register_taxonomy
(
'region'
,[
'attachment'
,
'documents'
],
$args
);
$labels
=
array
(
'name'
=>
'Country'
,
'singular_name'
=>
'Country'
,
'search_items'
=>
'Search Country'
,
'all_items'
=>
'All Country'
,
'parent_item'
=>
'Parent Country'
,
'parent_item_colon'
=>
'Parent Country:'
,
'edit_item'
=>
'Edit Country'
,
'update_item'
=>
'Update Country'
,
'add_new_item'
=>
'Add New Country'
,
'new_item_name'
=>
'New Country Name'
,
'menu_name'
=>
'Country'
,
);
$args
=
array
(
'labels'
=>
$labels
,
'hierarchical'
=>
true
,
'query_var'
=>
'true'
,
'rewrite'
=>
'true'
,
'show_admin_column'
=>
'true'
,
);
register_taxonomy
(
'country'
,[
'attachment'
,
'documents'
],
$args
);
// apply tags to attachments
function
wptp_add_tags_to_attachments
()
{
register_taxonomy_for_object_type
(
'post_tag'
,
'attachment'
);
}
//
add_action
(
'init'
,
'wptp_add_taxonomy'
,
0
);
\ No newline at end of file
add_action
(
'init'
,
'wptp_add_tags_to_attachments'
);
...
...
Please
register
or
sign in
to post a comment