Created
April 21, 2009 13:08
-
-
Save beastaugh/99131 to your computer and use it in GitHub Desktop.
Hide WordPress' Categories widget on certain pages
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 | |
/* | |
Plugin Name: Hide Categories Listing | |
Plugin URI: http://tarskitheme.com/ | |
Description: Hide the Categories widget on certain pages. | |
Author: Benedict Eastaugh | |
Version: 1.0 | |
Author URI: http://extralogical.net/ | |
*/ | |
function maybe_hide_categories_widgets($sidebars) { | |
if (!(is_page() || is_single())) return $sidebars; | |
// Add page IDs to this list, e.g. | |
// $hide_categories_on = array(1, 4, 9); | |
$hide_categories_on = array(); | |
if (in_array(get_the_ID(), $hide_categories_on) | |
|| get_post_meta(get_the_ID(), 'hide_categories', true)) | |
foreach($sidebars as $id => $sidebar) | |
foreach($sidebar as $i => $widget) | |
if (strpos($widget, "categories-") === 0) | |
unset($sidebars[$id][$i]); | |
return $sidebars; | |
} | |
add_filter('sidebars_widgets', 'maybe_hide_categories_widgets'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment