Title: conditional statement for a category
Last modified: August 22, 2016

---

# conditional statement for a category

 *  Resolved [Anne](https://wordpress.org/support/users/anne-wsib/)
 * (@anne-wsib)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/conditional-statement-for-a-category/)
 * I have put in the following code and get an error
    Parse error: syntax error,
   unexpected $end in xxxxxxx/wp-content/themes/simone-child/functions.php on line
   22.
 *     ```
       <?php /*
   
         This file is part of a child theme called simone-child.
         Functions in this file will be loaded before the parent theme's functions.
         For more information, please read https://codex.wordpress.org/Child_Themes.
   
         Add your own functions below this line.
         ========================================== */ 
   
       // theme's functions.php or plugin file
       add_filter( 'if_menu_conditions', 'my_new_menu_conditions' );
   
       function my_new_menu_conditions( $conditions ) {
       $conditions[] = array(
       	'name'		=>	'Schedule 2', //name of condition
       	'condition'	=>	'is_custom_category' //condition
       ;
   
       function is_custom_category() {
       	return is_category('sched2');
       }
       }
       ```
   
 * [https://wordpress.org/plugins/if-menu/](https://wordpress.org/plugins/if-menu/)

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

 *  Thread Starter [Anne](https://wordpress.org/support/users/anne-wsib/)
 * (@anne-wsib)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/conditional-statement-for-a-category/#post-5675502)
 * I could not get this working but found this instead which works perfectly
    [menu-items-visibility-
   control I just put the condition of schedule 1 or 2 so I can have the same site
   for different scheduled information AND it works with the language translate.
   Hope this helps someone
 *  [lbsteele](https://wordpress.org/support/users/lbsteele/)
 * (@lbsteele)
 * [11 years ago](https://wordpress.org/support/topic/conditional-statement-for-a-category/#post-5675609)
 * The closing parenthesis for the array is missing (it should be just before the
   semi-colon)
 *  [CHomko](https://wordpress.org/support/users/chomko/)
 * (@chomko)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/conditional-statement-for-a-category/#post-5675615)
 * You could also do it this way which is much simpler:
 *     ```
       add_filter( 'if_menu_conditions', 'my_new_menu_conditions' );
   
       function my_new_menu_conditions( $conditions ) {
         $conditions[] = array(
           'name'    =>  'Schedule 2', // name of the condition
           'condition' =>  function($item) {          // callback - must return TRUE or FALSE
             return is_category( 'sched2' );
           }
         );
   
         return $conditions;
       }
       ```
   
 *  Plugin Author [Andrei](https://wordpress.org/support/users/andreiigna/)
 * (@andreiigna)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/conditional-statement-for-a-category/#post-5675617)
 * Thank you for trying this plugin.
 * The code from ** CHomko** should work, thanks

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

The topic ‘conditional statement for a category’ is closed to new replies.

 * ![](https://ps.w.org/if-menu/assets/icon-256x256.png?rev=1862232)
 * [If Menu - Visibility control for Menus](https://wordpress.org/plugins/if-menu/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/if-menu/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/if-menu/)
 * [Active Topics](https://wordpress.org/support/plugin/if-menu/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/if-menu/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/if-menu/reviews/)

 * 4 replies
 * 4 participants
 * Last reply from: [Andrei](https://wordpress.org/support/users/andreiigna/)
 * Last activity: [10 years, 6 months ago](https://wordpress.org/support/topic/conditional-statement-for-a-category/#post-5675617)
 * Status: resolved