Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sorry if this is an ignorant question. I'm a first timer on working with rtl languages. Say we have a theme with standard style.css for English languages. so I use is_rtl() and this returns TRUE, we won't load the style.css and only rtl.css?

IF someone can provide an example on this on loading rtl.css on rtl languages and style.css on other languages (aside from the WordPress documentation which I already seen), I would be happy. Thanks.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

In your theme, you enqueue the stylesheet usually like this:

add_action( 'wp_enqueue_scripts',   't5_enqueue_style' );

function t5_enqueue_style()
{
    wp_enqueue_style(
        'theme-name-default',
        get_template_directory_uri() . '/css/default.min.css'
    );
}

The extra RTL stylesheet is enqueued here too, listing the default as dependency:

if ( is_rtl() )
{
    wp_enqueue_style(
        'theme-name-rtl',
        get_template_directory_uri() . '/css/rtl.min.css',
        array ( 'theme-name-default' )
    );
}

So the complete code is:

add_action( 'wp_enqueue_scripts',   't5_enqueue_style' );

function t5_enqueue_style()
{
    wp_enqueue_style(
        'theme-name-default',
        get_template_directory_uri() . '/css/default.min.css'
    );

    // extra RTL stylesheet

    if ( is_rtl() )
    {
        wp_enqueue_style(
            'theme-name-rtl',
            get_template_directory_uri() . '/css/rtl.min.css',
            array ( 'theme-name-default' )
        );
    }
}
share|improve this answer
add comment
if ( is_rtl() ) {
  <link rel="stylesheet" type="text/css" href="<? bloginfo('template_directory');?>/style_rtl.css" />
} else {
  <link rel="stylesheet" type="text/css" media="screen" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
}
share|improve this answer
1  
Never just print link elements. Use wp_enqueue_style(), so plugins can disable or replace the stylesheets per API. –  toscho Jul 19 '13 at 11:10
    
@toscho I think the question was about theme development not about plugins. Can you provide any case when developer need to replace stylesheet of the theme by his plugin ? –  Lilumi Jul 19 '13 at 11:19
    
I have written some plugins for the Twenty X themes, there are also plugins for Genesis themes or other frameworks. –  toscho Jul 19 '13 at 11:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.