0
這是我第一次爲WordPress構建一個插件。我瞭解了基礎知識,但現在我正試圖在右下角顯示div,更像是僅在首頁右下角的小彈出窗口。我上傳的PHP代碼不起作用,它不斷讓我的網站崩潰。PHP WordPress插件 - 如何僅在靜態主頁上顯示div?
我的錯誤在哪裏?
請解釋你的答案。謝謝!
代碼:
<?php
/*
Plugin Name: My First Plugin
Plugin URL: http://www.martinshabacom.ipage.com/test
Description: An awesome facebook popup plugin that will amaze you!
Author: Martin
Version: 1.0
Author URL: http://www.martinshabacom.ipage.com/test
*/
add_action('admin_menu', 'myfirstplugin_admin_actions');
function myfirstplugin_admin_actions() {
add_options_page('MyFirstPlugin', 'MyFirstPlugin', 'manage_options', __FILE__, 'myfirstplugin_admin');
}
function myfirstplugin_admin()
{
?>
<style>
.wrap {
width:100%;
height:auto;
}
.popup {
position:fixed;
bottom:0;
right:0;
width:325px;
height:200px;
background-color:#09f;
}
</style>
<div class="wrap">
<h1>Hello World!</h1><br>
<h4>Hope you like my awesome popup!</h4>
</div>
<?php if(is_front_page()) {
<div class="popup">Testing Div Tag On The Bottom Right Corner...</div>
}
?>
<?php
}
?>
當你說,「[[]]不斷崩潰我的網站」,你是什麼意思?你有沒有檢查Apache錯誤日誌輸出可能涉及? – Nathan
當我刪除插件文件時,我的網站又回來了! 我的意思是它顯示500錯誤的東西。 –
我建議查看Apache錯誤日誌以找出原因。此外,重要的是要注意確切的錯誤代碼(不是「500錯誤的東西」)。 – Nathan