Skip to content

Commit 28de3e7

Browse files
bredeclgfazioli
authored andcommitted
add documentation support for Columns on Custom Taxonomy
1 parent 022288a commit 28de3e7

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

pages/docs/ServicesProvider/custom-taxonomy-types.mdx

+24
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,27 @@ Add this new Service Provider to the list of providers in the `config/plugin.php
5656

5757
'custom_taxonomy_types' => [ '\WPKirk\CustomTaxonomyTypes\MyCustomTaxonomy' ],
5858
```
59+
60+
## Columns
61+
You may add columns to your Custom Taxonomy Type by adding the following code to your Service Provider:
62+
```php filename="plugin/CustomTaxonomyTypes/MyCustomTaxonomy.php" copy
63+
public function registerColumns()
64+
{
65+
return [
66+
'my_new_column_name' => 'Column Name',
67+
];
68+
}
69+
```
70+
71+
and also set the Column Content (where you can process the output), is *mandatory* to use `return` and not an `echo` statement
72+
73+
```php filename="plugin/CustomTaxonomyTypes/MyCustomTaxonomy.php" copy
74+
public function columnContent($string, $column_name, $term_id)
75+
{
76+
if ($column_name === 'my_new_column_name') {
77+
//... your logic here
78+
return 'your_new_content_here';
79+
}
80+
return $string;
81+
}
82+
```

0 commit comments

Comments
 (0)