how to go to other pages of my wordpress plugin

老子叫甜甜 提交于 2019-12-08 07:33:34

问题


I have a function that once is done should open a page called "nexpage.php" at the end of function I have used the following but none of them work.

include works but when I use this,it includes the new page in current page which I do not want, and need to close the current page and open the next page.

     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
     }

回答1:


Personally I would put the full link on the page so that there is no confusion on where you want it to go. I would specify the full path instead of the short path of the PHP file.

You can either use these for a Plugin:

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

or

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

or if Theme

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

There are other options as well. When creating setting pages for a plugin you can also create an array of submenu's by using add_menu_page() & add_submenu_page() and listing each page with a subpage-slug that you can point to a function or a page based on the name.

Reference:

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



来源:https://stackoverflow.com/questions/14873303/how-to-go-to-other-pages-of-my-wordpress-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!