get the current page id inside wordpress plugin page

前端 未结 6 885
情深已故
情深已故 2020-12-14 02:25

I need to get the current page id in WordPress plugin page outside the loop. And the code I wrote for getting current page id is in my plugin page.

6条回答
  •  轮回少年
    2020-12-14 02:50

    You get see all of the settings and variables in get_defined_vars() function:

    var_dump(get_defined_vars());
    

    In your case you need to get '_GET' and inside 'post'... The code should look like this:

    $tmp = get_defined_vars();
    var_dump($tmp['_GET']['post']);
    

提交回复
热议问题