I ahve added a custom column to the regular Posts list in Wordpress admin.
No custom taxonomies, it should just show tags that belong to a specific array of tags.
i.e: 1 column is for Country 2 column is for Province 3 column is for News Type 4 column is for Article Type etc.
There need to be 6 columns like this.
The regular tags column will still be there, containing the same tag that this custom column has, the custom columns are needed because of the back-end logic that was requested.
so for example:
The first custom column should only show tags assigned to a post tags that have specific TagIDs (52,128,97)
The second custom column should only show tags assigned to a post tags that have specific TagIDs (875,118,27,881)
and so on.
I understand that get_the_tags() uses get_the_terms(), but get_the_terms() can only have 2 parameters, $id and $taxonomy, which is 'post_tag' in this case.
This is where I have got so far:
add_filter('manage_posts_columns', 'posts_column_custom1_country', 10);
add_action('manage_posts_custom_column', 'posts_column_custom1_country_populate', 10, 3);
function posts_column_custom1_country($defaults) {
$defaults['customtag-country'] = __('Country');
return $defaults;
}
function posts_column_custom1_country_populate($column_name, $id) {
if($column_name === 'customtag-country') {
echo get_the_terms( $id, 'post_tag');
}
}
Notice: Array to string conversion in '...' Which is normal since what it returns is an array not a string.
How to I convert it to a string to show the actual tag names (comma separated) just like the default Tags column from Wordpress Core does?
Then how can this be set up to include an array of tagIDs so that it doesn't show all the tags assigned to the post.
There are 700+ tags used on the Wordpress site in question so excluding 780 for each of these columns only to show the 20 in the array would be a bad solution. How do I do something similar to the include parameter, which get_the_terms doesn't take unfortunately.