This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Reply To: Widget Area Assignments for Custom Post Types

#864
Jason Bobich
Keymaster

Hello,

Unfortunately this is currently not possible, although will be in the next round of theme updates. This doesn’t really help you now, but in the next update you’ll be able to accomplish this actually in several ways.

Since I hate the fact that I have to tell you this is a feature I’ve built in for the future but you can’t use it yet, I’ll try to provide you with a solution. Currently, I believe the only way would be to actually filter in the sidebar yourself from your Child theme’s functions.php.

Here’s an example:

function my_custom_sidebar( $config ){
	
	$post_type = 'your_post_type';
	$sidebar_id = 'your_sidebar_id';
	
	if( $post_type == get_post_type() ) {
		
		// Determine if sidebar has widgets
		$error = false;
		if( ! is_active_sidebar( $sidebar_id ) )
			$error = true;
		
		// Adjust config	
		$config['sidebars']['sidebar_right'] = array(
			'id' => $sidebar_id,
			'error' => $error
		);
		
	}	
	return $config;
	
}
add_filter( 'themeblvd_frontend_config', 'my_custom_sidebar' );

Just change the $post_type and $sidebar_id variables to fit what you’re doing. Also note that this would be specifically for the “sidebar_right” location, and the “location” that you’ve selected in the Widget Area Manager for whatever custom sidebar ID in your WP admin is irrelevant in this case.