2013-02-20 73 views

回答

2

內與這兩個答案的混合之前,我開始看的wordpress功能文檔。我找到了一些東西,並將它添加到我的wordpress站點上的header.php中。

<?php if (is_page('Page Title')) { ?> 
    <script type="text/javascript"> 
     window.setInterval(customRedirect, 3000); 
     function customRedirect() { 
     window.location = "http://www.google.com"; 
     } 
    </script> 
<?php } > 

因此,無論何時用戶輸入帶有該標題的頁面,都將進行重定向。謝謝。

1

這個JavaScript添加到您的頁腳:

window.setInterval(yourfunction, 10000); //100 seconds 

function yourfunction() { window.location = "http://www.yoururl.com"; } 
+0

我可以補充一點,但我用wordpress創建的頁面不是另一個html或php文件。我將如何指定它必須工作到哪個頁面? – 2013-02-21 20:15:25

2

在你的header.php添加以下代碼head標籤部分

<head> 
    <!-- your other meta element --> 
    <meta http-equiv="refresh" content="30;URL='http://example.com/'"> 
</head> 
+0

如果我編輯header.php,我將爲所有網站工作。我只想使用我在wordpress網站上創建的特定頁面。 – 2013-02-21 20:19:33

+0

@Camilo Aguilar。你可以在它之前放置條件語句。像<?php if($ post-> ID =='your specific page id'):?><?php endif; ?> – EmptySpaces 2013-02-26 08:25:16

2

有用,我發現從卡米洛的代碼片段引起了現場摔倒,所以我從改變最後一行:

<?php }> 

到:

<?php }; ?> 

,現在它的工作原理。

相關問題