Yes get_template_directory
:
get_template_directory(): string
Retrieves template directory path for the active theme.
Returns an absolute server path (eg: /home/user/public_html/wp-content/themes/my_theme), not a URI.In the case a child theme is being used, the absolute path to the parent theme directory will be returned. Use get_stylesheet_directory() to get the absolute path to the child theme directory.
To retrieve the URI of the stylesheet directory use get_stylesheet_directory_uri() instead.
https://developer.wordpress.org/reference/functions/get_template_directory/
There’s also get_stylesheet_directory
which refers to the current theme, whereas get_template_directory
always refers to the parent theme ( if there is no child theme then they will return the same value )
$svg = file_get_contents( get_template_directory() . '/file.svg' );
Related Posts:
- How do I edit the php/html for a particular post?
- Can WP plugins access files outside the installation folder?
- How to replace file_get_contents() with a WordPress Filesystem call
- Is it better to store images and other files in the root directory or the theme directory
- How to edit php code in WordPress Post file?
- Running rmdir function on post save
- Does WordPress create a new Linux user when creating a new WordPress blog?
- Adding regular php file to site
- php – Plugin/theme relative PATH/URI
- wordpress admin part is not accesbile after server shifting
- Apply function.php filter only if url not has /amp/
- How to route root path / to /xyz in nginx?
- I can’t load my images from a js file using wp_localize_script
- Right path for renaming a file in uploads folder
- Path for contact form file
- How to link the path of a folder situated in public.html for a random video player?
- What do ++ and *+ mean?
- How to fix the admin menu margin-top bug in WordPress 5.5?
- Cleaning up WordPress to improve performance?
- How can I modify the permalink via a filter?
- How build a custom login/register form with error handling?
- How can merge two arrays values in one array and save in database
- Network installation giving errors when viewing or adding a user
- Create a post variable processing page
- The best way to customize “nav-menu-template.php” to add if the ‘link_before’ is “checkbox”
- List all categories but exclude current post category on single post page
- How Do I Add User Custom Field to REST API Response?
- Bare minimum to include in PHP file to use WP functions? [duplicate]
- Woocommerce, recognize the loop of related products
- Using FirePHP with WordPress
- How to return output of the new wp gallery block for automatically Link images To Media file
- Can an array be used as a meta_query value?
- WordPress different language footer text
- How do I target the child theme with get_bloginfo();?
- If Meta Checkbox is checked, do something?
- Output 2 items within the Loop
- Can I use HTTP POSTs? Is there a better alternative?
- Will simple function names in a class structure conflict with other plugins?
- Image as Sales Badge
- Getting a specific post values to another div or modal
- How can i upload images in an admin page?
- WP grandchild categories in nested ul li
- Modify HTML structure of fields in woocommerce checkout form
- Retrieve $_POST data submitted from external URL in WordPress(NOT API)
- How to improve my WordPress filter to include empty custom fields
- Update results, Before deleting the related category [closed]
- Add / Update Custom Fields After Select Pictures in Media Window
- How to debug this search & replace strings snippet?
- How to Return in WordPress Function php file?
- Limit Taxonomy Output in Conditional Statement
- wp_redirect only works on main site and not on other sites
- Can’t retrieve element with WordPress default @fetch_rss();
- I have a snippet to redirect all users to a maintenance page. How do I exclude users with admin role?
- How to filter custom taxonomy term name, slug, and description?
- Rewrite with pagination /foo/page/2/ to posts of a given category, page 2
- Is this a correct usage of ob_start() in my WordPress project?
- How do I get my Javascript scripts working?
- How to remove the space before the ellipsis in excerpt?
- Website completely messes up when logging out
- Searching Posts Programmatically in a WordPress Plugin
- Unique PHP on each Page
- How do I include an external PHP file in a subdir WordPress install?
- Page Options Saving But Not Updating In Backend
- Drupal is going Symfony. Would WordPress benefit from doing the same? [closed]
- WordPress Settings API unable to save settings
- How to redirect non logged in mobile users to page on same site?
- Decode and Decrypt Azure B2C OpenID Authorization Token, Use Response in API Call (Example Token Within)
- How do I use an iFrame for my header in WordPress twenty seventeen?
- Use WPQuery to match to specific repeater row in post
- Restrict wordpress access to logged users only
- Execute Shortcode in Textfile
- Featured images duplicating and replacing next image
- Set a cookie inside the 404.php theme page
- How best to check if a user is from China and hide content?
- Bring Font Awesome icons inside menu A tags
- Use WP Cron to Clear a Page Cache?
- Local WordPress from Git repo, where to set document root?
- Sort WooCommerce data with WP-CRON?
- Array sorting assistance
- Apply filters when loading post via ajax
- Relative post date in recent posts list
- Shortcode At top of Page – PHP 5.5 vs 5.4 – ob_start();
- How to fetch results from database
- PHP version or config prohibiting script from working properly
- Page downloads as file in Chrome
- How to implement conditional PHP in Footer
- Change background image based on tags
- How keep woocommerce users separeted in multisite install and keep admins on network
- How to show only part of product name in category page – WordPress with woocomerce
- For each loop will not append to the_content hook
- Pagination not working properly
- Detecting IP Address of someone using ‘copy’ function [closed]
- Functions.php file in a custom child theme messed up without backup
- How do you create a front end form that enables the editing of member-specific custom fields in WordPress?
- Endpoint exists and shows up in My Account dashboard. Need to add endpoint to My Account DROPDOWN menu in Porto theme
- Adding features to Gutenberg without theme.json
- Connection refused by WordPress
- How to temporarily set the featured image for a post when the post is loaded
- The theme doesn’t load css and JS files doesn’t load in functions.php
- Custom signup redirection to external URL not working