Programmatically rewriting slug through functions.php but returns 404

You can try this plugin, I think this will work for you. You can directly change the URL on your page by clicking on URL to whatever you want.

Hope this would be helpfull.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)