Title: Plugin modification to make it work
Last modified: August 22, 2016

---

# Plugin modification to make it work

 *  [dpplopez2](https://wordpress.org/support/users/dpplopez2/)
 * (@dpplopez2)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/plugin-modification-to-make-it-work/)
 * The first fresh installation of this plugin didn’t work for me. I created a specific
   category to be hidden anywhere and assigned this category to one post (just for
   testing), but nothing happened: the post was anywhere, like it was before using
   the plugin.
 * As my WordPress version is 4.0 I thought it could be some compatibility problem,
   and I digged into the code.
 * I have finally got a working implementation with two small changes (I have not
   checked if they are both required or it is just the first one… anyway, now it
   works). The main problem was with getting the category_hide option: the code 
   was using explode as if categories would be a comma-separated list of categories,
   but they where actually an array. I just got rid of explode.
 * The function I changed is wp_hide_category, which is located in the wp_hide_category.
   php plugin file. The following code shows my modified version of the function(
   changes are indicated with comments):
 *     ```
       function wp_hide_category($query) {
           if(!is_admin() /* && $query->is_main_query() */ ) {
               $wp_hide_category_hide_place = get_option('wp_hide_category_hide_place');
               // Modified from original: $category_hide = explode(',', get_option('wp_hide_category_id'));
                $category_hide = get_option('wp_hide_category_id');
               if(!empty( $wp_hide_category_hide_place)) {
                   foreach($wp_hide_category_hide_place as $template_name){
                       $call_name = 'is_' . $template_name;
                       if($query->$call_name()){
                           if(!empty($category_hide)) {
                               foreach($category_hide as $cat_id) {
                                   // Modified from original: $query->set('cat', '-' . $cat_id);
                                   $query->set('category__not_in', $cat_id);
                               }
                           }
                       }
                   }
               }
           }
       }
       ```
   
 * Hope this helps.
 * [https://wordpress.org/plugins/wp-hide-category/](https://wordpress.org/plugins/wp-hide-category/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [albertodg](https://wordpress.org/support/users/albertodg/)
 * (@albertodg)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/plugin-modification-to-make-it-work/#post-5497011)
 * Hi dpplopez2!
 * Does this plugin really hide anything? I can see the posts of a hidden category
   without any problem.
 *  Thread Starter [dpplopez2](https://wordpress.org/support/users/dpplopez2/)
 * (@dpplopez2)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/plugin-modification-to-make-it-work/#post-5497018)
 * Yes, it does for me (after applying the modification I posted before).
 * Just to clarify, the mod I posted is not available in the online plugin version:
   I just modded the plugin installed in my wordpress site. I’ve tried to suggest
   this correction to the plugin author, but haven’t found the way to do it (that’s
   why I posted my solution here).
 * So, summarizing: it works, but you will need to modify the code of your installed
   plugin, just as I did.
 * Hope this helps!
 *  [leonuts](https://wordpress.org/support/users/leonuts/)
 * (@leonuts)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/plugin-modification-to-make-it-work/#post-5497100)
 * Thanks for the fix buddy, much appreciated
 *  [Manux_oS](https://wordpress.org/support/users/manux_os/)
 * (@manux_os)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/plugin-modification-to-make-it-work/#post-5497106)
 * The code doesn’t work as it should i think.
 * I have a post inlcuded in 2 categories.
    I hide the 1 category and the post disapears.
 * I want to use this plugin so i can hide “Featured” category which is used for
   an image – post slider.
 * thanks
 *  [Janell2](https://wordpress.org/support/users/janell2/)
 * (@janell2)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/plugin-modification-to-make-it-work/#post-5497147)
 * Fixed it, many, many thanks!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Plugin modification to make it work’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-hide-category.svg)
 * [WP Hide Category](https://wordpress.org/plugins/wp-hide-category/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-hide-category/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-hide-category/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-hide-category/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-hide-category/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-hide-category/reviews/)

 * 5 replies
 * 5 participants
 * Last reply from: [Janell2](https://wordpress.org/support/users/janell2/)
 * Last activity: [11 years, 2 months ago](https://wordpress.org/support/topic/plugin-modification-to-make-it-work/#post-5497147)
 * Status: not resolved