Admin URL to my plugin's page

后端 未结 2 855
再見小時候
再見小時候 2021-01-17 09:57

My plugin is basically a link display page, for instance if you want to display a page with links to other websites.

In wp-admin I have a menu item on the left side

2条回答
  •  心在旅途
    2021-01-17 10:47

    You get the concrete URL to admin.php by using the admin_url function:

    admin_url('admin.php'); # http(s)://localhost/wp-admin/admin.php
    

    That function chooses the proper sheme (http/https) based on your Wordpress configuration for you so you do not need to care about it. Same for the path to the admin. The only thing you need to specify is the file name (admin.php).

    And in your concrete example you add the page query-info part:

    $url = admin_url('admin.php?page=customlinks');
    wp_redirect($url); 
    

提交回复
热议问题