I have a locally hosted site that uses bootstrap to create a carousel with pictures from the upload folder. I currently have the bootstrap markup using the source of the pictures, but I fear when I load the site to a live server those links are not going to work anymore?

Is there a dynamic way to get to the upload folder, maybe with the use of an inbuilt WordPress function, so that the path to the pictures that are used in the carousel always work?

1 Answer 1


Take a look at wp_upload_dir here https://developer.wordpress.org/reference/functions/wp_upload_dir/

$upload_dir = wp_upload_dir();

var_dump( $upload_dir );

$upload_dir will comprise of the following return values:

'path'    - (string) Base directory and subdirectory or full path to upload directory.
'url'     - (string) Base URL and subdirectory or absolute URL to upload directory.
'subdir'  - (string) Subdirectory if uploads use year/month folders option is on.
'basedir' - (string) Path without subdir.
'baseurl' - (string) URL path without subdir.
'error'   - (string|false) False or error message.

  • 1
    Thank you very much, kind sir
    – Neil Meyer
    Dec 28, 2019 at 9:00
  • You are welcome.
    – Adam
    Dec 28, 2019 at 10:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.