Skip to content

Instantly share code, notes, and snippets.

@Perun
Last active March 31, 2016 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Perun/652329a92bf9aa0cf2122bacefa8b590 to your computer and use it in GitHub Desktop.
Save Perun/652329a92bf9aa0cf2122bacefa8b590 to your computer and use it in GitHub Desktop.
Bestimmte Kategorien ( Name + Verlinkung) im Frontend ausblenden. Im Bsp. werden die Kateg. "Aktualisieren" + "Rechtschreibung" unsichtbar, nicht aber Artikel dieser Kategorien. Nützlich wenn man eine Sortierung für interne Zwecke braucht. Siehe auch den Artikel http://www.perun.net/?p=8547 | Gefunden: Torsten Landsiedel (https://github.com/Zodi…
<?php
function hide_categories_terms($terms, $post_id, $taxonomy) {
// Kategorienamen ausblenden (den Slug eintragen und durch Komata trennen)
$exclude = array('aktualisieren', 'rechtschreibung');
if (!is_admin()) {
foreach($terms as $key => $term){
if($term->taxonomy == "category"){
if(in_array($term->slug, $exclude)) unset($terms[$key]);
}
}
}
return $terms;
}
add_filter('get_the_terms', 'hide_categories_terms', 10, 3);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment