get_template_directory()
returns a filesystem path– that is, it returns the path to the file as it would appear if you were browsing it on the local machine via a file browser.
Return Values
(string)
Absolute path to the directory of the current theme (without the trailing slash).https://codex.wordpress.org/Function_Reference/get_template_directory
That is what you are seeing. The function works correctly (based on my interpretation of your question, anyway).
You want get_template_directory_uri()
instead, which will give you a path relative to your web server root and which is what get_bloginfo('template_directory');
gives you.
Related Posts:
- What’s the difference between home_url() and site_url()
- Prevent “main” WPMU site_url() being returned in functions
- Functions.php code that only runs on localhost?
- Best Practice for Syncing Local Development With Staging Development [closed]
- What do the schemes login, login_post, admin, and relative mean?
- dynamic site link for future migration in echo do_shortcode()
- site_url is not honoring scheme
- Advantages and disadvantages of using automatic-feed-links
- How to change the markup WordPress inserts for post images
- When tax_query used, results disappear (0 =1 produced)
- wp_get_attachment_image returns different image size
- Limit the length of the Author Profile Biographical Text
- Convert hyphen to underscore in permalinks
- wp_mail not running inside Cron
- Remove product description from product archive page
- Logging in redirects to correct page but shows logged out content until forced refresh
- Displaying Widgets
- How can I stop a function from encoding an entity?
- Display WooCommerce subscriptions for user [closed]
- Increment price for Woocommerce Minicart [closed]
- Change woocommerce products weight varation based its product category or tags? [closed]
- Function to “Press Update Button” on all posts
- Change WP attachment name to postid during upload only for post type
- Completely disable RSS feeds on WP 5.5.2 and show a 404 page instead of die();
- Check if row exists before inserting
- Missing argument 2 for a custom function widgets_init
- Removing the main link to Jetpack from the menu
- Defining a global array in functions.php?
- Get the 5 lastest Featured Posts from a category
- Set quantity of woocommerce product on page visit [closed]
- get_post_type() in in_array doesn’t work for some reason
- Is it possible to change any of the HTML/URL returned from the_category()
- How to remove set_post_thumbnail_size() in child themes?
- Post thumbnail not showing in WP admin area for custom post type
- Activate small php condition at footer over page template
- How to insert custom widget in custom sidebar in theme activation?
- Fatal error: Cannot redeclare when switching themes
- How to load jQuery in the footer – nothing works for me
- How can I grab the video id of youtube?
- Specify number of posts for sub-category page
- how to en-queue jQuery to load before the tag
- Passing variable as add_shortcode argument
- comments_popup_link without echo?
- Can’t filter wp_get_attachment_link
- Impossible to call wordpress function inside an include?
- How to customize the_archive_title()? Cannot figure out how to change the value it produces [duplicate]
- If ACF field is empty show different value [closed]
- What is the text that appears beside the page titles in the list of pages in the WP admin?
- Two functions with different arguments and add_actions, but identical code
- How to fix get_the_category function returning incorrect slug?
- How to edit the Tags within the image file URLs?
- Disabling visual editor on a specific post
- Disable wp_is_mobile()
- Auto log in hook is requiring a page refresh
- Testing for a shortcode using a function. 404 page throwing PHP Notice
- How to get post revisions in my custom rest API? [closed]
- Possible to merge these two functions?
- Strip div From Excerpt
- How to properly set custom logo size?
- The_content and Preg_replace in loaded Iframe [closed]
- Hide tab Buddypress profile for visitors, not logged in users
- Image Crop Not Working
- Add a mature content warning to first-time visitors
- Show Featured Image in else statement
- Function to check if custom page is used by page?
- Simplest Way to Build Custom Archives Page?
- Filter for replacing the WP_query object for a given category
- Custom user role still showing up after deletion, ideas?
- How to Display WooCommerce Product Price in WooCommerce Archive
- Woocommerce Variable Product Dropdown for Custom Shop Template
- Bizarre Child Menu Issue on WP Site
- get variables data from functions.php to template wordpress (without global variables)
- how to increase connection time
- Shortcode to insert default text and change one word throughout it?
- Its my first time trying to create a website , I got an error Please help
- Reference multiple style sheets, clearing styles for permalink page, custom fields for css
- Add schema to Search result page’s body. Tried using is_search
- Drop down list code for sidebar
- Shortcode Initialization in a Custom Theme
- Hide disclaimer from summary excerpts
- Load scripts into an AJAX div
- restrict uploaded image size and fixed image display size
- Code executes outside of Loop while same code gives ‘Uninitialized string offset’ notice inside a while loop
- Function not receiving string from shortcode
- Restricted images only for logged user. (hidden url)
- Open image size links in a page instead of direct image link
- Allow tags and attributes in post and pages content
- Override parent theme function that is not hooked or in the functions.php file
- Syling Custom Fields echo’s from from functions.php
- Function to get thumbnail img source
- Syntax for a function in order to get post’s title in JSON encoded response [closed]
- Comment Function
- WP Custom Comment Callback Not Responding
- Do something when user creates post (that’s pending)
- Add product to cart from functions.php
- How I can show short content with short tag
- Vimeo video play button color function
- User’s Comments Number: Storing it in a meta field for different uses
- Show one post per author and order by custom field
- Loading newest dependency javascript module file in functions.php