Site icon Hip-Hop Website Design and Development

Add a filter inside an action init

Hello in the init action, I would like to add a filter to a fairly large function to modify variables in the $vars array, for example the WordPress post ID.

That is to say:

    add_action( 'init',function(){
        //code
    
        add_filter( 'query_vars',function($vars){
            $vars[] = array('ID' => $myid);
             return $vars;
    
        });
    });

Is this possible?

EDIT: I am doing A/B/C tests of pages and with the same url I want to show a page with another ID, (i.e. edit the ID of the current post to display the complete content of another post).