,

Add The7 meta boxes to custom post types

The7 theme

The7 theme comes with dedicated meta boxes like Sidebar options, footer options, page header options etc for pages, posts and portfolios. But these options will not be available if you add a new custom post type or post types from other plugins, however, it can be added easily as below

Assume ‘cp_test’ is your custom post type, adding the following code in your child theme functions.php will add The7 sidebar, footer, fancy header and slideshow metaboxes to cp_test post type.

function add_dt_metaboxes_custom( $pages ) {
		$pages[] = 'cp_test';
		$pages[] = 'cp_books'; // add each post type in new line
		return $pages;
}

add_filter( 'presscore_pages_with_basic_meta_boxes', 'add_dt_metaboxes_custom' );

If you are using custom template for post types, will need to add define few configs and call hooks to display these options in front end.

$config = Presscore_Config::get_instance();
$config->base_init();

get_header();

//and hooks like
do_action( 'presscore_before_loop' );
do_action( 'presscore_after_loop' );
do_action('presscore_after_content');

Plase refer to ../dt-the7/single.php, archive.php for better understanding of these hooks. You can also try to duplicate the same files and make necessary changes for custom post type.

Programmatically controlling sidebar

If you don’t want to add The7 meta boxes to your custom post type, but only want to control the default sidebar settings (default to right)

add_action( 'get_header', 'cp_sidebar_filter', 10 );

function cp_sidebar_filter() {

$config = Presscore_Config::get_instance();

if( 'cp_test' == get_post_type() ) {
	$config->set( 'sidebar_position', 'left'  ); 
	$config->set( 'sidebar_widgetarea_id', 'sidebar_1' ); 
	$config->set( 'footer_show', '1' ); 
	$config->set( 'footer_widgetarea_id', 'sidebar_2' );
}
}

To disbale sidebar use config value disabled.

$config->set( 'sidebar_position', 'disabled'  );