将页面加载到同一页面

时间:2014-03-14 22:20:53

标签: php html wordpress

我正在开发插件到wordpress。我在管理菜单中单击我的插件,在窗口中出现用户登录。在用户登录下,我做了一个新的注册帐户,如超链接(带有html标签a)。

<a class="hyper" href="file.php">Register new account</a>

但此链接重定向到    localhost / my_project / wp-admin / file.php 但此文件不存在。我的文件位于 localhost / my_project / wp-content / plugins / my_plugin / file.php。如何在点击超文本后将此文件显示在用户登录的同一窗口中?

我在href属性中尝试wp_redirect标头,但它仍然重定向到wp-admin。

我的代码

<a class="hyper" href="<?php wp_redirect( home_url()."/wp-content/plugins/my_plugin/file.php"); ?>">Register new account</a>

wp_database中siteurl的值为 http protocol:// localhost / my_project /

感谢您的回答

编辑:我发现我不需要使用plugin_url因为它重定向到插件网址。我只需要将页面(file.php)加载到同一页面中。它与slug_name相关的东西(我的意思是$ prefix_hook)

3 个答案:

答案 0 :(得分:0)

所以路径为../wp-content/plugins/my_plugin/file.php

 <a class="hyper" href="../wp-content/plugins/my_plugin/file.php">Register new account</a>

答案 1 :(得分:0)

您可以尝试使用plugins_url( 'file.php' , __FILE__ )了解有关函数here

的更多信息

* 编辑: *您也应该查看Determining Plugin and Content Directories

答案 2 :(得分:0)

不要将wp_redirect用于链接,它应该是php代码中的一个动作。如果在wp_redirect之前已经启动任何输出,它将失败。然后你需要exit()命令。如果您需要一个变量的url,请使用函数来设置它。