How to link wordpress avatars with discourse?

That code needs to be added to your WordPress code, not to Discourse. The easiest place to add it is to your theme’s functions.php file. There is some risk in editing your functions.php file on a live site. Before you do it you should be sure that you can access you have some way of accessing your theme’s files in case you make a mistake.