如何在wordpress的自定义插件中获取页面id


How to get the page id in custom plugin of wordpress

我是Php和word press世界的新手。我想用页面id编辑插件。我尝试了以下选项来获取页面id,但一无所获。

get_the_ID()
$post->ID
var_dump($wp_query)

all返回null。

我正在编辑的php文件位于插件文件夹的一个名为inludes的文件夹中

但是get_the_ID()在这个文件夹之外的php文件中运行良好,该文件是插件的根文件夹。

plugin folder
  include
     edit_page.php(Here i'm facing problem) 
 plugin.php

如能及时回复,我们将不胜感激。

提前谢谢。

尝试:

global $post;
$page_ID = $post->ID;
var_dump($page_ID);