Skip to content

Instantly share code, notes, and snippets.

@muhfaris
Created October 11, 2016 04:19
Show Gist options
  • Save muhfaris/6e5b4caffdaf081af94d64229242d84e to your computer and use it in GitHub Desktop.
Save muhfaris/6e5b4caffdaf081af94d64229242d84e to your computer and use it in GitHub Desktop.
Exclude Category - Menyembunyikan beberapa kategori, menggunakan fungsi
<?php
//Pilihan_Atas : 11
//Pilihan_Bawah : 12
//Featured : 13
//Function mode
//
function the_category_filter($thelist,$separator='') {
if(!defined('WP_ADMIN')) {
//list exclude
$exclude = array('Pilihan_Bawah','Pilihan_Atas','Featured');
$cats = explode($separator,$thelist);
$newlist = array();
foreach($cats as $cat) {
$catname = trim(strip_tags($cat));
if(!in_array($catname,$exclude))
$newlist[] = $cat;
}
return implode($separator, $newlist);
}else
return $thelist;
}
add_filter('the_category','the_category_filter',11,12,13);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment