Wordpress插件:在静态主页上显示div

时间:2015-10-07 00:12:58

标签: php jquery html wordpress wordpress-plugin

我正在构建一个小WordPress右下角的弹出窗口。我遇到了一些麻烦。这是我第一次构建WordPress插件。无论如何,我无法弄清楚如何在我网站的前静态页面上显示它。 请帮帮忙?

  

这是我在Plugin文件夹中唯一的文件。我的位置在哪里   误?

这是我的代码:

<?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>


    <div class="popup">
<?php if(is_front_page()) {
        Hello world
    }
?>
    </div>

<?php
}
?>

1 个答案:

答案 0 :(得分:0)

我认为您希望使用wp_footer操作向页脚添加输出,而不是admin_menu。 wp_footer用于在主题调用wp_footer()方法时添加输出。它是网站上浮动元素的有用位置。

所以它会是

  LINQDataClassesDataContext DB = new LINQDataClassesDataContext();
    var test (from s in DB.Student_Courses select s);
    dgvDataTab1.DataSource = test;

并确保您的主题包含&lt;?php wp_footer()?&gt;适当的地方。

相关问题