Last active
March 31, 2016 14:39
-
-
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…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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