How to get the upload folder in the theme files on WordPress

Ok a quick tip, How to get the upload folder in a theme file on WordPress.

Why we need this?

Well you might want to link to a pdf file or some static file from the theme file.

How to do this?

First get the upload folder into a variable,

<?php $upload_dir = wp_upload_dir(); ?>

Then use that variable in the url to get the path of the file,

<a href=”<?php echo $upload_dir[‘baseurl’]; ?>/Testfile.pdf”ย  target=”_blank”>Test link</a>

Simple as that.


6 thoughts on “How to get the upload folder in the theme files on WordPress

    • Hi this is for getting “wp-content/uploads” folder in the theme file. I think your trying this in a wordpress blog hosted at so this is not relevant for you unless your developing your own theme. ๐Ÿ™‚

      • I see, okay. Well to clarify, I bought a thesis2 theme at it is telling me to upload it, but no where on my screen do I have that option! Not sure if you are able to tell me why this is, but I appreciate the help if you know :).

      • Well its like this. blogs are kind of like a WordPress website with limited functionality. It doesnt allow you to just upload WordPress themes, plugins you purchase from out side. You need to go into the Appearance/Themes Tab and search and purchase through that. If you want to customize you can upgrade your Blog for that I think you need to pay $30+ annually. If you want a really customized version of WordPress you should go to and download the installation and do a custom theme development or use the theme you purchased. Or if you go into any webhosting provider these days they allow custom WordPress installations. I think you should try one of those if your interested. But the best option for you now is to purchase a theme through your Appearance/Themes tab. ๐Ÿ™‚

      • I bought a domain name a couple of years ago (through WordPress) but I guess that doesn’t help me with anything! Disappointing. Wish I knew better how to do this. Thanks so much for your help :).

Let me know what you think .. :)

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.