2012-11-15 94 views
1

我做了在WordPress 2語言的網站,我需要說:WP:如果聲明

如果HTML方向RTL使用一些代碼,否則使用其他代碼...

我已經試過這與我在的Joomla使用傳統的方式

<?php if($this->direction=="rtl"){ ?> 
/images/slider/01.jpg 「ALT = 」滑塊01「 標題= 」#htmlcaption「/> /images/slider/02.jpg」 ALT = 「Slider 02」title =「#htmlcaption」/> /images/slider/03.jpg「alt =」Slider 03「title =」#htmlcaption「/> /images/slider/04.jpg」alt =「Slider 04」標題=「#HTML字幕「/> هذامثاللمايمكنانيكتبهنا。 /images/slider/01.jpg 「ALT = 」滑塊01「 標題= 」#htmlcaption「/> /images/slider/02.jpg」 ALT = 「滑塊02」 標題= 「#htmlcaption」 /> /images/slider/03.jpg「alt =」Slider 03「title =」#htmlcaption「/> /images/slider/04.jpg」alt =「Slider 04」title =「#htmlcaption」/> PROVIDING具有成本效益和可靠的海運服務 This is a example of a HTML caption with a link。 這個是一個鏈接HTML標題的例子。 這個是一個鏈接HTML標題的例子。

但它總是說,有一個致命的錯誤。我想我需要定義$this爲 html頁面,但怎麼說,在PHP?

:使用$這個時候不是在C對象方面:\的appserv \ WWW \ WordPress的\可溼性粉劑內容\主題\ WP \的index.php上線7

+0

什麼致命的錯誤?以及'//一些代碼'是什麼? –

+0

@MichaelBerkowski說了些什麼以及向我們解釋發生了哪條線,以及這條線上的代碼是什麼。 – h2ooooooo

回答

2

它似乎是我們構建到另一個名爲「language_attributes()」的函數中。試試這個:

// if (function_exists('is_rtl')) # You may need to utilize this if is_rtl() is not defined 
if(is_rtl() == 'rtl'){ 
    // DO RTL code 
}else{ 
    // DO LTR code  
} 

主要基於以下信息:

http://core.trac.wordpress.org/browser/tags/3.4.2/wp-includes/general-template.php#L0

http://wpml.org/2011/06/creating-right-to-left-rtl-wordpress-sites/

http://codex.wordpress.org/Right-to-Left_Language_Support

+0

它的工作原理!非常感謝 –

0

試試這個:

$script_name=$_SERVER['SCRIPT_NAME']; 
+0

此編輯器排除我的代碼...我的代碼是一些html行 –