The dog pees or poos on the floor? You take them to the pee, you point their face at it, tell them “no!” in a stern voice, then put them where they’re supposed to go.
If you don't give the feedback immediately, the dog is not going to be able to properly connect to the action of peeing/pooping, but rather the existence of the urine/poo being agitating to the human.
You gotta catch them in the act and provide the feedback immediately for it to be effective.
ITT: people who only read the title and did not open the link