Hide / exlude specific wordpress tags in frontend

Posted in: Newspaper
Post count: 17

Hi,

we want to hide specific wordpress post tags in the frontend, because we need them for internal purposes.
We want to hide them via php code, because css is not the best solution (because single tags have no unique css classes/ids)

Could you show us the php file, where tag output in posts is generated or which code we have to implement to exclude/hide specific and defined tags? I tried several plugins to hide tags in the frontend, but they don’t work.

Example:
A news-post has 3 tags: “news”, “topnews”, “local”
We want to hide the tag “topnews”.

Thanks in advance!

Post count: 17

Ok.. finally i found a solution that works.

If someone needs the code, just put this in your functions.php and modify the cases.

function exclude_tags($tags) {
foreach ($tags as $tag)
switch ($tag->name) {
case ‘topnews’:
case ‘other-tag’:
break;
default:
$newtags[] = $tag;
}
return $newtags;
}
add_filter( ‘get_the_tags’, ‘exclude_tags’);

Post count: 7909

Hi,

Thank you for sharing it also for the other theme’s users!

Have a nice day!

Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.