Add a filter inside an action init

Hello in the “action init” to fairly large function, but I would like to add a filter to modify the vars variables, for example the wordpress post ID. That is to say:

add_action( 'init',function(){
    ///code
    //code

    add_filter( 'query_vars',function($vars){
        $vars[] = array('ID' => $myid);
         return $vars;

    });
});

This is possible?

Read more here: Add a filter inside an action init

Leave a Reply

Your email address will not be published. Required fields are marked *