Any widgets added from AppearanceWidgets (or from the customizer) are shown in a sidebar. There may be times where you need to remove a sidebar from a specific location.

Removing all sidebars

All sidebars can be removed from the theme, regardless if there are widgets present.

/**
 * Remove all sidebars
 */
add_filter( 'themedd_show_sidebar', '__return_false' );

Removing sidebars for all posts

Sidebars can be removed for all posts. Once the sidebar is removed, the post content will be automatically centered and made slimmer.

/**
 * Remove the sidebar for all posts
 *
 * @param boolean $return
 *
 * @return boolean $return Whether the sidebar should be shown
 */
function themedd_snippet_remove_sidebar_all_posts( $return ) {

	// Remove the sidebar for all posts.
	if ( is_singular( 'post' ) ) {
		$return = false;
	}

	return $return;

}
add_filter( 'themedd_show_sidebar', 'themedd_snippet_remove_sidebar_all_posts', 10, 1 );

Removing the sidebar for a specific post

The sidebar can be removed on a specific post. Once the sidebar is removed, the post content will be automatically centered and made slimmer.

/**
 * Remove sidebar for a specific post
 *
 * @param boolean $return
 *
 * @return boolean $return Whether the sidebar should be shown
 */
function themedd_snippet_remove_sidebar_single_post( $return ) {

	// Remove the sidebar for a post with the ID of 1234
	if ( is_single( 1234 ) ) {
		$return = false;
	}

	return $return;

}
add_filter( 'themedd_show_sidebar', 'themedd_snippet_remove_sidebar_single_post', 10, 1 );

Removing sidebars for all pages

Sidebars can be removed for all pages.

/**
 * Remove the sidebar for all pages
 *
 * @param boolean $return
 *
 * @return boolean $return Whether the sidebar should be shown
 */
function themedd_snippet_remove_sidebar_all_pages( $return ) {

	// Remove the sidebar for all pages.
	if ( is_singular( 'page' ) ) {
		$return = false;
	}

	return $return;

}
add_filter( 'themedd_show_sidebar', 'themedd_snippet_remove_sidebar_all_pages', 10, 1 );

Removing the sidebars for a specific page

Themedd has two page templates (Slim and Full Width) that you can add to pages to hide the sidebar. There are times however when you need to remove a page’s sidebar programmatically.

/**
 * Remove sidebar for a specific page
 *
 * @param boolean $return
 *
 * @return boolean $return Whether the sidebar should be shown
 */
function themedd_snippet_remove_sidebar_page( $return ) {

	/**
	 * Remove the sidebar for the "About" page.
	 * See https://developer.wordpress.org/reference/functions/is_page/
	 */
	if ( is_page( 'about' ) ) {
		$return = false;
	}

	return $return;

}
add_filter( 'themedd_show_sidebar', 'themedd_snippet_remove_sidebar_page', 10, 1 );

PHP should be added to your child theme's functions.php file.