WordPress Paths An Easy Reference
One of the most painful parts of working with WordPress Themes is learning how the paths work. So consider this your cheat sheet for Word Press paths.
Use these to determine the path for assets:
<?php echo esc_url( home_url() )?> will give you this path:
http://wordpressnation.com
<?php echo get_template_directory_uri(); ?> will give you this path:
http://wordpressnation.com/wp-content/themes/themefast-framework-doc
Example: <img src=”<?php echo esc_url( home_url() )?>/images/your-image.png”>
Is the proper way to add your-image.png image in the images directory
Site URL: <?php esc_url( site_url() )?> This also works <?php esc_url( home_url() )?> but it seems that site is the proper one
Template URL: <?php get_template_directory_uri(); ?>
Plugins URL: <?php plugins_url(); ?>
Admin URL: <?php admin_url(); ?>
Includes URL: <?php includes_url(); ?>
Content URL: <?php content_url(); ?>
Uploads Directory:
URLS
URL current upload subdirectory: (based on date): <?php $upload_dir = wp_upload_dir(); $upload_dir[‘url’]; ?>
URL Base upload directory: <?php $upload_dir = wp_upload_dir();$upload_dir[‘baseurl’]; ?>
PATHS
Actual Path to the current subdirectory (based on date): <?php $upload_dir = wp_upload_dir(); $upload_dir[‘path’] ; ?>
Actual Path to base upload directory: <?php $upload_dir = wp_upload_dir(); $upload_dir[‘basedir’]; ?>
Current upload subdirectory only: <?php $upload_dir = wp_upload_dir(); $upload_dir[‘subdir’]; ?>
Current file directory (works on all files- has trailing slash: <?php $path = plugin_dir_path( $file ); ?>
*Note: none have trailing slashes but they do have the http:// in front- except paths have no http://*
See what private AI could do for your business
Book a free 30-minute AI Readiness Assessment — no obligation.
Book Your Free Consultation →