Alter The Main Sidebar Display

This is a Developer Level doc.

If you're unfamiliar with PHP and/or editing files, codes and templates, as well as with resolving possible conflict, please seek help from a professional. Under our Support Policy, we don't provide support for modifications and customization.

If you want to use a different sidebar on your custom post types called "gallery", for example, use the following PHP snippet:

function my_custom_sidebar_display( $sidebar ) {
	// Return a different sidebar for custom post type 'gallery'
	if ( is_singular( 'gallery' ) ) {
		return 'my_custom_sidebar_id';
	}
	// Return theme defined sidebar area
	else {
		return $sidebar;
	}
}
add_filter( 'ocean_get_sidebar', 'my_custom_sidebar_display' );

Replace gallery with the name of your custom post type.
Adjust my_custom_sidebar_id per your need.

All PHP snippets should be added via a child theme's functions.php file.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.