Hope this will help you :
pass your variable like this , URL structure should be like this :
http://localhost/base_folder/controller_name/method_name/username/post_id
suppose ur controller name is welcome and method name is index, with username shamer and post id 4; it will become like this :
http://localhost/base_folder/welcome/index/shamer/4
in anchor should be like this :
<a href="<?=site_url('welcome/index/shamer/4');?>">your link</a>
In Welcome controller get username and post id in your index method like this :
public function index($username, $post_id)
{
echo $username;
echo $post_id;
}
For more : https://www.codeigniter.com/user_guide/general/controllers.html#passing-uri-segments-to-your-methods