I’m creating a site where the pages are divided into two sections: Hebrew and English. I need the Hebrew pages to use a template that basically looks the same as the English pages, but everything is switched around to right-to-left.
I created a copy of the style sheet and called it style-hebrew.css. In the copy, I made all the relevant changes so that everything is flipped around, which basically meant writing direction: rtl
in a bunch of places, and floating things to the right instead of left, and vice versa. But now I needed a way to call this style sheet on the Hebrew pages.
First, I created a page template called hebrew-page.php. In this template, I replaced
<?php get_header(); ?>
with
<?php include ('header-hebrew.php'); ?>
Then I copied the header.php file and renamed it header-hebrew.php. In this file, I replaced the usual call to the style sheet:
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
with the call to my new Hebrew style sheet:
<link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/style-hebrew.css" type="text/css" media="screen" />
Now, in the admin, whenever a Hebrew page is created, they just have to make sure to select the Hebrew Page template from the Page Template drop-down menu on the right-hand panel.
This method can be used for any site that needs to call different styles for different pages or categories. Just create another style sheet and header.php files, and call them in the appropriate places.
There may be a more efficient way to do this, but I have yet to discover it.