How do I only allow downloads that are referred from my domain?

The link you provided deals with restricted access based on user permissions. But I gather from your question that you want to block hotlinking as a whole.

If you don’t already have one, you should create a .htaccess file in your root WordPress directory (same location as wp-config.php). Add the following to it:

# WP writes the following block
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
# WP-written-block ends here

# BLOCK HOTLINKING TO IMAGES
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?yourwebdomain\.com(/)?.*$ [NC]
RewriteRule .*\.(jpe?g|gif|bmp|png)$ [F,NC]

The Block Hotlinking part can be modified to block files of other mime types.

You could also Google for “wordpress htaccess hotlinking”

Update – Google indexing images

You can add google.com to the accepted referrers. Your images will show up on Google search but any site other than yours (and google.com) won’t be able to directly link to them.

# BLOCK HOTLINKING TO IMAGES
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(.+\.)?google\.com [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?yourwebdomain\.com(/)?.*$ [NC]
RewriteRule .*\.(jpe?g|gif|bmp|png)$ [F,NC]