Skip to content

Commit 48bc9fb

Browse files
Add example snippet to make taxonomies private to the developer docs
1 parent ecb22e5 commit 48bc9fb

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

hookdocs/meta.json

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"useful-snippets": {
3+
"title": "Useful snippets"
4+
},
25
"wp-cli": {
36
"title": "WP-CLI Commands"
47
}

hookdocs/useful-snippets.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## Make ClassifAI taxonomies private
2+
3+
Some users might want to set some of the taxonomies provided by the plugin private, so that their archive pages won't be generated (and thus indexed by search engines).
4+
5+
In order to do that, we can use a filter provided by WordPress Core, namely `register_{$taxonomy}_taxonomy_args` ([see here for the documentation](https://developer.wordpress.org/reference/hooks/register_taxonomy_taxonomy_args/)).
6+
7+
For example, let's say we want to make the `classifai-image-tags` taxonomy private, we would need to add this snippet to either our theme `functions.php` or our custom plugin.
8+
9+
```php
10+
namespace MyPluginOrTheme;
11+
12+
add_filter( 'register_classifai-image-tags_taxonomy_args', __NAMESPACE__ . '\override_taxonomy_args' );
13+
14+
function override_taxonomy_args( $args ) {
15+
$args['public'] = false;
16+
return $args;
17+
}
18+
```

0 commit comments

Comments
 (0)