Title: Conditional Action Hook Question
Last modified: August 24, 2016

---

# Conditional Action Hook Question

 *  [nomis](https://wordpress.org/support/users/nomis/)
 * (@nomis)
 * [11 years ago](https://wordpress.org/support/topic/conditional-action-hook-question/)
 * Hi again,
 * I’m working with a Genesis theme which uses Action Hooks to add and remove widget
   areas. My site divides posts into two main categories. The two blogs are completely
   separate from each other and are accessed by separate main menu items. Clicking
   on “Blog” takes you to a normal blog, and clicking on “Tutorials” takes you to
   a portfolio template page which leads through to completely separate tutorial
   posts.
 * So far I have registered two widget areas to the ‘genesis_after_header’ hook.
   One widget appears on the Blog Page, and the other appears on the Tutorials Page.
   They both contain custom menus. This means that when you’re in the Blog, you 
   can filter the blog categories, and when you’re in Tutorial you can filter the
   tutorial categories. The Tutorial Submenu filters by removing categories from
   the portfolio page. This is the code that I’m using, and it works just fine:
 *     ```
       // **************************** BLOG SUBMENU WIDGET ****************************
       //* rise - Register blog-submenu widget area
       genesis_register_sidebar( array(
       	'id'            => 'blog-submenu',
       	'name'          => __( 'Blog Submenu', 'epik' ),
       	'description'   => __( 'Place submenu for Blog Page here', 'epik' ),
       ) );
   
       //* rise - Hook blog-submenu widget area after header
       add_action( 'genesis_after_header', 'add_blog_submenu' );
       function add_blog_submenu() {
       	if  (is_singular(post) && is_category('Blog') || is_category('Blog_Web') || is_category('Blog_Photos') || is_category('Blog_General') || is_page('Blog'))
       		genesis_widget_area ('blog-submenu', array (
       		'before' => '<div class="wrap"><div class="blog-submenu widget-area">',
       		'after'  => '</div></div>',
       		)
       	);
       }
   
       // ***************************** TUTS SUBMENU WIDGET ***************************
       //* rise - Register tuts-submenu widget area
       genesis_register_sidebar( array(
       	'id'            => 'tuts-submenu',
       	'name'          => __( 'Tuts Submenu', 'epik' ),
       	'description'   => __( 'Place submenu for Tuts Page here', 'epik' ),
       ) );
   
       //* rise - Hook tuts-submenu widget area after header
       add_action( 'genesis_after_header', 'add_tuts_submenu' );
       function add_tuts_submenu() {
       	if (is_page('Illustrator Tutorials') || is_page('Sublime Text Tutorials') ||  is_page('Photoshop Tutorials') || is_page('Tutorials') || is_category('Tuts_PS') || is_category('Tuts_Ill') || is_category('Tuts_ST'))
       		genesis_widget_area ('tuts-submenu', array (
       		'before' => '<div class="wrap"><div class="tuts-submenu widget-area">',
       		'after'  => '</div></div>',
       		)
       	);
       }
       ```
   
 * However, the filter menus (Submenus) were not showing up on single posts. So 
   I added (is_singular(‘post’) to the Blog Submenu code:
 *     ```
       //* rise - Hook blog-submenu widget area after header
       add_action( 'genesis_after_header', 'add_blog_submenu' );
       function add_blog_submenu() {
       	if  (is_singular(post) || is_category('blog_web') || is_category('blog_photos') || is_category('blog_general') || is_page('blog'))
       		genesis_widget_area ('blog-submenu', array (
       		'before' => '<div class="wrap"><div class="blog-submenu widget-area">',
       		'after'  => '</div></div>',
       		)
       	);
       }
       ```
   
 * This worked fine, but the blog-submenu was now also showing on the Tutorial single
   posts. So I added (is_singular(post) && is_category(‘blog’). My thought was that
   this would only add the blog-submenu to single posts that also had the Blog category
   attached to them.
 *     ```
       //* rise - Hook blog-submenu widget area after header
       add_action( 'genesis_after_header', 'add_blog_submenu' );
       function add_blog_submenu() {
       	if  (is_singular(post) && is_category('blog') || is_category('blog_web') || is_category('blog_photos') || is_category('blog_general') || is_page('blog'))
       		genesis_widget_area ('blog-submenu', array (
       		'before' => '<div class="wrap"><div class="blog-submenu widget-area">',
       		'after'  => '</div></div>',
       		)
       	);
       }
       ```
   
 * But this made the blog-submenu disappear from ALL single posts. So I added this(
   is_singular(post) && !is_category(‘Tutorials’). My thought was that this would
   only add the blog-submenu to single posts that did NOT have the Tutorials category
   attached to them.
 *     ```
       //* rise - Hook blog-submenu widget area after header
       add_action( 'genesis_after_header', 'add_blog_submenu' );
       function add_blog_submenu() {
       	if  (is_singular(post) && !is_category('Tutorials') || is_category('Blog_Web') || is_category('Blog_Photos') || is_category('Blog_General') || is_page('Blog'))
       		genesis_widget_area ('blog-submenu', array (
       		'before' => '<div class="wrap"><div class="blog-submenu widget-area">',
       		'after'  => '</div></div>',
       		)
       	);
       }
       ```
   
 * This did not remove the blog-submenu from single posts that had the Tutorials
   category attached.
 * **So basically, I want to add the blog-submenu widget to single posts that have
   the Blog category, but not the Tutorials category. Can anyone help?**

Viewing 1 replies (of 1 total)

 *  Moderator [Jose Castaneda](https://wordpress.org/support/users/jcastaneda/)
 * (@jcastaneda)
 * THEME COFFEE MONKEY
 * [11 years ago](https://wordpress.org/support/topic/conditional-action-hook-question/#post-6160765)
 * Have you tried asking on the [studiopress forums](http://www.studiopress.com/forums/)?
   They would know the codebase a lot better than some on these forums since many
   on here don’t have access to the code.

Viewing 1 replies (of 1 total)

The topic ‘Conditional Action Hook Question’ is closed to new replies.

## Tags

 * [genesis](https://wordpress.org/support/topic-tag/genesis/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Jose Castaneda](https://wordpress.org/support/users/jcastaneda/)
 * Last activity: [11 years ago](https://wordpress.org/support/topic/conditional-action-hook-question/#post-6160765)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
