admin管理员组

文章数量:1404924

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?

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?

Share Improve this question asked Dec 26, 2019 at 10:37 Neil MeyerNeil Meyer 1137 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Take a look at wp_upload_dir here https://developer.wordpress/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.
*/

本文标签: customizationIs there a way to dynamically get to your uploads folder