Tagged: rtl
Hey, I want to build a website that has a hebrew version (in addition to the english version) is there a possibility to make specific pages on the website in RTL mode while the others are LTR?
Thanks
Hey kfir_menashe,
To enable the RTL only on some pages on your site please add this code to the end of your functions.php file in Appearance > Editor:
function enqueue_rtl() {
if ( is_page( array( 597, 'features', 'meet-the-team' ) ) ) {
wp_enqueue_style( 'avia-rtl', get_template_directory_uri()."/css/rtl.css", array(), '1', 'screen' );
}
}
add_action( 'wp_enqueue_scripts', 'enqueue_rtl', 100 );
you can change the pages it changes to RTL in the “array” in the code above, just add “Page IDs” or “Page Titles” or “Page Slugs”
Best regards,
Mike
Thanks for the answer Mike but it does not seem to work.
I added the code to the functions.php and added a page to check but I see no change.
Since Im not really that femiliar with html can you please write an example of how you would enter a page to the array using the page slug ?
thanks
Hi,
The code above is a working example with the slug “meet-the-team”, Please include an admin login in the Private Content area and the test page you wish to use.
Perhaps you are missing a bracket from the code.
Best regards,
Mike
It works, Thanks
is there a way to do the same for posts and portfolio items?
Hi,
Glad to hear that it is working for you, instead of using if ( is_page )
you could use if ( is_singular )
is_singular() is for existing single post of any post type (post, attachment, page, custom post types including portfolio items).
Please explain if you want to define when this is active or when it is not active. Do you want the RTL on most pages & posts or just a few?
Best regards,
Mike