Archived topic
Different header layout per language
14 replies · Started by Yael on May 3, 2021
Hello
I'm currently building a Hebrew English website and would like to display the header differently based on language. I built this site years ago using Astra Pro
And you see how the header layout goes from LTR and then RTL depending on language.
For the life of me I can't remember how I achieved that but wondered if there's a way to do the same thing with GP.
I know the customizer settings applies globally, not per language and there's no custom layouts in the site posted above.
Any ideas?
Hi Yael,
There're some conditional menu plugins can help you achieve this.
For example, If Menu.
You could do some google research for that :)
Nope, that just applies to menu, not header layout. Okay, it'll just remain a mystery how I accomplished this previously :)
Hi there,
the Theme has RTL Styles included - so when an RTL language is selected it should do that automatically for you.
Hmm, it doesn't do that automatically though.
Password: meitar
I've currently the primary navigation to float left.
So - bit of trial and error here as this is not my strong point.
1. I would expect the layout to be set as per you would want it displayed in the English language so nav set float right.
2. Then the RTL language should invoke the RTL styles which will then swap that setting around.
yes, that is how I originally had it but nothing happened when I went to Hebrew so I decided to set default to float right.
But either way, (primary nav float right or left) nothing happens when you change language.
Hmmm... odd - can you set it to the layout for the english language and then i can take a look at whats going on?
You mean LTR (float right), yes? If so, I've just now done that
I asked Tom to have a look as that isn't how i expect it to behave and hes more knowledgable than i on this matter. He should be online soon
Okay, thank you.
Hi there,
Looks like this could be a bug.
Does this do anything?:
add_filter( 'option_generate_settings', function( $settings ) {
if ( is_rtl() ) {
$settings['nav_position_setting'] = 'nav-float-left';
}
return $settings;
} );
Hello Tom,
No, it doesn't; attaching the contents of my GP Child theme functions.php file
<?php
/**
* GeneratePress child theme functions and definitions.
*
* Add your custom PHP in this file.
* Only edit this file if you have direct access to it on your server (to fix errors if they happen).
*/
function generatepress_child_enqueue_scripts() {
if ( is_rtl() ) {
wp_enqueue_style( 'generatepress-rtl', trailingslashit( get_template_directory_uri() ) . 'rtl.css' );
}
}
add_action( 'wp_enqueue_scripts', 'generatepress_child_enqueue_scripts', 100 );
add_filter( 'option_generate_settings', function( $settings ) {
if ( is_rtl() ) {
$settings['nav_position_setting'] = 'nav-float-left';
}
return $settings;
} );
Oh, wait; that did fix it Tom. Sorry I forgot to clear the cache!
Thank you so much.
Glad I could help :)