Skip to content

Instantly share code, notes, and snippets.

@thecodepoetry
Last active March 24, 2021 07:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thecodepoetry/822895548f7701f4086a to your computer and use it in GitHub Desktop.
Save thecodepoetry/822895548f7701f4086a to your computer and use it in GitHub Desktop.
To change default pre selected sidebar position in The7 and Armada
function dt_change_default_sidebar() {
global $DT_META_BOXES;
if ( $DT_META_BOXES ) {
if ( isset($DT_META_BOXES[ 'dt_page_box-sidebar' ]) ) {
$DT_META_BOXES[ 'dt_page_box-sidebar' ]['fields'][0]['std'] = 'left'; // use disabled to disable sidebar
}
}
}
add_action( 'admin_init', 'dt_change_default_sidebar', 20 );
Update (Cotober 2020): You can now use the preset settings, please refer to
https://support.dream-theme.com/knowledgebase/change-default-sidebar-position/
@thecodepoetry
Copy link
Author

Add this cod in child theme's functions.php

@gottschild
Copy link

Hi, does this still work with the latest Theme Update?

@thecodepoetry
Copy link
Author

Yes, it works, if not try changing hook priority to 30 or something

@jodamo5
Copy link

jodamo5 commented Jan 26, 2016

Thanks! Changing it to priority 30 worked for me.

add_action( 'admin_init', 'dt_change_default_sidebar', 30 );

@sintos
Copy link

sintos commented Jul 14, 2016

I have changed the priority to 30 and it made 'left' as default.
Any other value i should use ?

@davidddp
Copy link

davidddp commented Aug 4, 2016

If I change the last value of 20 to 10. If I work.
I can change the value to 10 without danger?
What does this value?

@djassimo
Copy link

You can just change the function in the template the7 in file inc/helpers/html-helpers.php and changing this

`function presscore_main_container_classes( $custom_class = array() ) {

	$classes = $custom_class;
	$config = presscore_config();

	switch( $config->get( 'sidebar_position' ) ) {
		case 'right':
			$classes[] = 'sidebar-right';
			break;
		case 'disabled':
			$classes[] = 'sidebar-none';
			break;
		default :
			$classes[] = 'sidebar-left';
	}

	if ( ! $config->get( 'sidebar.style.dividers.vertical' ) ) {
		$classes[] = 'sidebar-divider-off';
	}

	$classes = apply_filters( 'presscore_main_container_classes', $classes );
	if ( ! empty( $classes ) ) {
		printf( 'class="%s"', esc_attr( implode( ' ', (array)$classes ) ) );
	}
}`

@apysais
Copy link

apysais commented Mar 8, 2018

DO not edit nor hack the code, if you want you're sidebar to be on the left across the theme, here is what I did:

add_filter( 'presscore_main_container_classes', 'apyc_sidebar_default_left', 1 );
function apyc_sidebar_default_left($classes) {
   return isset($classes[0]) ? $classes[0] = 'sidebar-left':$classes;
}

@germanpericon
Copy link

Great solution !!!! Thank you.

@trendy20twenty
Copy link

it is not working!

@meyer744
Copy link

does anyone have a solution to make the default disabled? Tried editing the filter and did not work out

@jemoh
Copy link

jemoh commented Jan 18, 2020

You're a genius!!! Thank you.

@sagarponnur
Copy link

add_filter( 'presscore_main_container_classes', 'apyc_sidebar_default_left', 1 );
function apyc_sidebar_default_left($classes) {
return isset($classes[0]) ? $classes[0] = 'sidebar-left':$classes;
}

You saved my day, Thank you.

@thecodepoetry
Copy link
Author

This is an old hack, You can now use the built-in preset settings to change default sidebar postion, please refer to documentation
https://support.dream-theme.com/knowledgebase/change-default-sidebar-position/

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