How to get page id in custom wordpress plugin

I am new to php and word-press world. I want to change the plugin with the page id. I tried the following options to get the page id but I couldn't pull anything.

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

      

everything returns null.

The php file I am editing is inside the folder that contains the plugins folder

But get_the_ID () works fine in a php file that is outside of this folder and this is the root folder of the plugin.

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

      

Your prompt reply will be highly appreciated.

Thanks in advance.

+3


source to share


1 answer


Try:



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

      

+1


source







All Articles