I think you have to be a little careful because it depends on what you are trying to do.
If you are using a child theme get_template_directory();
will still go to the parent theme. However get_stylesheet_directory();
will go to the current theme, child or parent. Also, both these functions return absolute server paths.
If you wanted a fully formed URI, for links or images, you should use get_template_directory_uri();
or get_stylesheet_directory_uri();
using the correct one for the reasons stated.
Summary
get_stylesheet_directory()
: file path to current Theme directoryget_stylesheet_directory_uri()
: url path to current Theme directoryget_template_directory()
: file path to parent Theme directoryget_template_directory_uri()
: url path to parent Theme directory
Related Posts:
- Plugin path comes wrongly
- Autoloading & Namespaces in WordPress Plugins & Themes: Can it Work?
- What process do you use for WordPress development? [closed]
- What is the advantage of using wp_mail?
- Should Plugin Folders Include a Blank index.php File?
- Where to store PHP files created by plugin / themes
- Should I create a theme or a plugin?
- Include third party Javascript library which is not included in WordPress
- Is there widely accepted phpDoc syntax for documenting which hook calls a function?
- Where do I start from
- WP 3.3 Tooltips API?
- wp_remote_get doesn’t work with secure connections https?
- How do I Make a Theme “plugin-ready”?
- Authoritative answer on which boots first – Plugins or Themes?
- How to Add Font Awesome Icons to WordPress Menus?
- How to Use WordPress Color Picker API in Custom Post Type Metabox
- Custom theme sufficient or custom plugin neccessary for this feature set?
- How to use filter hook ‘post_updated_messages’ in coherence with action hook ‘save_post’
- How to create custom home page via plugin?
- How to debug WordPress correctly?
- Custom user profile, registration, login page with theme
- Featured Image not showing in admin
- Plugin base URL
- Whats the difference between blog_info(‘stylesheet_url’) difference get_stylesheet_uri()
- Paging on a future post loop?
- What for the tables ending with the meta used in database of wordpress?
- How to check if a stylesheet is already loaded?
- Use WP_Theme::scandir function to scan a plugin directory. Is there a way?
- Problem with is_active_sidebar?
- Is Dreamweaver CS5 a serious choice for theme/plugin development?
- What allows a template file from plugin to be copied in child theme and overridden?
- WordPress security issue to output data from user input from theme option form
- Change template dynamically
- WordPress add_admin_page not working even parameters are correct?
- Customizer: widget-synced triggers twice
- Change the ‘published on’ text?
- Get Current Menu Location inside Nav_Walker
- Howto: Use Custom Post Types as Submenu Items in Admin
- Extending theme PHP class in plugin
- How to access noticeOperations from withNotices
- How to get boolean value from register_meta properly?
- what is the difference between these phares?
- How to export post meta with images in wordpress
- Password field is empty when using wp_signon();
- How to limit number of number of categories displayed by categories widget
- Strange Situation When Try To Retrieve Github Gist Using wp_remote_get
- How to hide or rename “X” and “x-child” references in website source?
- How to create a backend for a custom theme?
- wp_nonce_field displaying twice
- Plugin is not generating title tags on any pages or posts
- Is it necessary to do validation again when retrieving data from database?
- Update Data parameter of a wp_localize_script() call
- WP Plugin Running before jQuery
- get_the_tags with separator control?
- How to only load css for used blocks on frontend
- How to get path or root of plugin folder, not file or dir?
- Add child pages to submenu automatically
- Why in this archive page that call query_posts() function show only the last 10 posts?
- Why enqueue styles on hook?
- PHP File_exist() not working – Checking if File Exist in WordPress Theme Directory
- Why would you use esc_attr() on internal functions?
- Invalid hook call on save, not edit when using swiper slider
- Proper way to use useSelect
- How to find where an object first instantiatiation
- How to get post image root URL?
- Full documentation about $args for register_rest_route?
- modify show UI of a registered taxonomy
- Using function from enqueued .js file in theme in plugin?
- Using HTML links within translatable string
- How to get terms for taxonomy
- How to remove/replace current page template?
- WordPress dynamic widget by location?
- Loading Images from Javascript on the Front End
- Adjust query on single
- Using password protection to load different page elements?
- Anyone using unzip_file successfully? It uploads the zip but doesn’t extract it!
- WP_Query order posts by category
- WordPress Favicon not Working For Images/Videos/PDFs
- Can’t upload image via submitting custom post from frontend
- Need Help to make a logic for editing posts in Frontend
- How can we stop showing short code in create or edit post section
- Is it possible to develop themes and plugins locally while still allowing content to be updated directly in the admin dashboard?
- Error Connecting to Database WHEN Installing WordPress on XAMPP [Tried All the Usual Stuff] (Pics Included)
- How can I measure CPU and RAM used by my theme or plugin
- set a custom post type to a taxonomy term programmatically in metabox
- Custom premium registration form and profile page for a WordPress Web Application
- My enqueue admin style function doesn’t work because of ?=ver
- Can i prevent the effect of the_title filter on the dashboard’s posts/pages titles?
- How to destroy or dispose wordpress uploder/manager?
- To remove rendering of menus and header, plugin or theme?
- To remove rendering of menus and header, plugin or theme?
- How can I add recent posts to menu like mashable
- How to Register/Link to .js Files in WordPress Dynamicaly in Header.php
- Display Data’s metabox in page
- Ajax functions – no access to wp-admin.php only online
- How can I make my website with wordpress having on-spot editing feature as compared to concrete5 CMS?
- Loading jQuery library from WordPress admin
- Using tag or inline style attribute?
- how to insert content into wp_head after loop_end
- How to create A – Z List with pictures?