Custom GET Parameters In Plugin's Admin Page

In my plugin's options page, I'd like to have custom GET parameters. WordPress already has a ?page=<slug>

In my plugin's options page, I'd like to have custom GET parameters. WordPress already has a ?page=<slug> GET parameter, so simply linking to something like ?myparameter=value won't work.

I though of reading the page parameter, and then linking to something like: ?page=<slug>&myparameter=value. This seems workable, but I don't know if its the best practice. The complexity of my plugin really doesn't warrant sub-pages for now.

So is this the best practice or am I missing something?

In my plugin's options page, I'd like to have custom GET parameters. WordPress already has a ?page=<slug> GET parameter, so simply linking to something like ?myparameter=value won't work.

I though of reading the page parameter, and then linking to something like: ?page=<slug>&myparameter=value. This seems workable, but I don't know if its the best practice. The complexity of my plugin really doesn't warrant sub-pages for now.

So is this the best practice or am I missing something?

Share Improve this question edited Oct 30, 2019 at 16:13 Eje 1654 bronze badges asked Oct 30, 2012 at 11:54 AgilEAgilE 1451 silver badge6 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

I'd recommend using add_query_arg():

  $url = add_query_arg(array(
            'foo'=>'bar',
            'custom'=>'var',
            'page'=>'myadminpage'
           ), admin_url('admin.php'));

The second argument, admin_url('admin.php'), is optional - and if omitted it uses the url of the current page you are on.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745042725a4607908.html

相关推荐

  • Custom GET Parameters In Plugin&#39;s Admin Page

    In my plugin's options page, I'd like to have custom GET parameters. WordPress already has a ?page=<slug>

    8小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信