Black Friday Sale! Get up to $30 off GP Premium! Learn more ➝

Reply To: Override Settings

Home Forums Support Override Settings Reply To: Override Settings

Home Forums Support Override Settings Reply To: Override Settings

#109673
Tom
Lead Developer
Lead Developer

Absolutely, we can set the page layout using a function and a filter, as seen in some examples here: http://generatepress.com/knowledgebase/choosing-sidebar-layouts/

For you, you could do something like this:

add_filter( 'generate_sidebar_layout','generate_custom_post_type_sidebar_layout' );
function generate_custom_post_type_sidebar_layout( $layout )
{
 	// Get post type
 	$type = get_post_type();

 	// If our post type is named "my_post_type", set the sidebar
 	if ( 'my_post_type' == $type )
 	 	return 'both-left';

 	// If our post type is named "recipes", set the sidebar
 	if ( 'recipes' == $type )
 	 	return 'left-sidebar';

 	// Or else, set the regular layout
 	return $layout;

 }

How to add PHP: http://generatepress.com/knowledgebase/adding-php-functions/

Hope this helps 🙂