First hook to use current page post id


I’m trying to find the first hook that will pass the current post ID, as I would like to update the current post (by getting its ID) and the variables submitted to that page.

This is the code I’m using:

class my_class {

    public function __construct(){

        add_action( 'init', array( $this, 'my_method' ) );

    public function my_method( $atts ){

        // do my stuff with current page id here.
        // even just: echo post id and die();.


Any hook, action or filter, and which one to use and why.

, Nabeel Khan 2 years 2020-01-12T08:42:26-05:00 0 Answers 72 views 0

Leave an answer