oh dear...
first welcome to YorkieTalk. I'm sure you'll learn a lot here.
and now to the issue at hand here. your dog is just a puppy. he has NO idea what you want him to do yet! Yorkies are a difficult breed to house break. take us for example, our yorkie just turned a year old and still has some accidents.
also, I dont think he's doing it just to get your attention. He probably just has to go outside. Always keep an eye on him..never let him out of your sight. soon, you'll start to realize when he's telling you he has to go..he'll start giving you "signs." once that happens, you grab him and run lol.
when he does what he's supposed to do, make sure you praise him. praise praise and more praise. throw him a little mini party haha.
and don't hit him. He doesn't know he did anything wrong. he's still a baby..he hasn't learned good from bad yet. Hitting him isn't going to help the situation, it will just make him fearful of you. and I know you don't want that.
good luck! and I hope you stick around! we'd love you see pictures of your puppy!