Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@deckerweb
Last active March 10, 2023 11:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deckerweb/18a141ee5a7a32f056c1f720cd0a1d28 to your computer and use it in GitHub Desktop.
Save deckerweb/18a141ee5a7a32f056c1f720cd0a1d28 to your computer and use it in GitHub Desktop.
Conditionally remove sidebar from category archives for Astra Theme
<?php
/** Do NOT include the opening php tag */
add_filter( 'astra_page_layout', 'ddw_astra_conditionally_remove_category_sidebar' );
/**
* Conditionally remove sidebar in Astra
*
* @see https://codex.wordpress.org/Conditional_Tags
* @link https://gist.github.com/deckerweb/18a141ee5a7a32f056c1f720cd0a1d28
* @author David Decker - DECKERWEB
*/
function ddw_astra_conditionally_remove_category_sidebar() {
/** Category specific */
if ( is_category( '9' ) || is_category( 'food' ) ) {
return 'no-sidebar';
}
/**
* Fallback if above conditional is not met:
*/
// get default archive layout for post type
$layout = astra_get_option( 'archive-' . get_post_type() . '-sidebar-layout' );
// return this archive layout, if not set, use the website default layout
return ( 'default' == $layout || empty( $layout ) ) ? astra_get_option( 'site-sidebar-layout' ) : $layout;
} // end function
@4n0nim9
Copy link

4n0nim9 commented Mar 10, 2023

i don't want sidebar on a specific page, using is_page...but I don't know if doing it, can help me ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment