如何转到我的wordpress插件的其他页面


how to go to other pages of my wordpress plugin

我有一个函数,一旦完成,应该在函数末尾打开一个名为"nextpage.php"的页面。我使用了以下内容,但它们都不起作用。

include工作,但当我使用它时,它会在当前页面中包含我不想要的新页面,并且需要关闭当前页面并打开下一个页面。

     function myfunc(){
           .........
          include "nextpage.php";
           echo "<a href='nextpage.php'>NewPage</a>";   <<does not find it
          include_once "nextpage.php";                << open it in the page so javascript does not work and login wont disappear
           header('Location: nextpage.php');  <<it refresh the page but does not open the nextpage
     }

就我个人而言,我会把完整的链接放在页面上,这样就不会混淆它的去向。我会指定PHP文件的完整路径,而不是短路径。

您可以将这些用于插件:

echo '<a href="'.plugins_url('PluginFolderName/nextpage.php').'">New Page</a>';

echo '<a href="'.plugin_dir_path( __FILE__ ).'/nextpage.php">New Page</a>';

或者如果主题

echo '<a href="'.get_template_directory_uri().'/nextpage.php">New Page</a>';

还有其他选择。当为插件创建设置页面时,您还可以使用add_menu_page()&add_submenu_page(),并用子页面段塞列出每个页面,您可以根据名称指向函数或页面。

参考:

http://codex.wordpress.org/Function_Reference/add_menu_pagehttp://codex.wordpress.org/Function_Reference/add_submenu_page