Yes get_template_directory:
get_template_directory(): stringRetrieves 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 do I check if a string contains a specific word?
- How do I replace part of a string in PHP? [duplicate]
- cURL 28 error after switch from to brew php 7.2 on localhost
- Get only enqueued styles and scripts of the current theme
- Query WooCommerce orders grouped by several order statuses
- WordPress “Link has expired” error on updating posts
- Creating a post with the REST API, curl and oauth returning 401 error
- add_filter to post-gallery and remove all ‘s?
- Custom post type column which compares dates?
- How to output a permanently delete comment link?
- Ajax template: how to handle head section
- get image url inside the content in wordpress?
- Automatically check the option “Enable stock management at product level” on product creation
- Rectangle avatars
- WordPress shop: enable custormers to select product color using image thumbnails on Custom Fields
- Edit format of Paginate_Links()
- delete an array element when its date expires
- save_post vs post_updated
- Modify Maximum upload file size text
- Upload a json file in php [closed]
- WordPress Site front End and Back End Loading Slowly
- How do I implement a .diff changeset from core.trac.wordpress.org locally?
- Evaluations of two wordpress security plans against php code injection attack
- What does $wpdb->get_row return?
- Change the URL of an image from wp_get_attachment_image_src except in the frontpage
- What is an equivalent of single_cat_title for getting the slug of the category?
- Count the number of custom posts per user
- Second transition_post_status hook fired instead of the first
- getting logged in user info (wp-load.php) from parent directory
- How wp-cron can run in background if PHP is single threaded?
- How do I get post attachments in menu_order in WordPress?
- Why does wp_head hook my functions to the beginning of my source code?
- Noscript not working as it should in wordpress site
- Pass argument to event hook
- Translate wordpress date from Italian to English
- wp_insert_post: array only. wp_update_post: array|object (?)
- What is the difference in the WP memory limits?
- Different Subdomain changes page content
- Removing the comment function within wordpress
- Get related product based on subcategory selected from category id with ID 142
- Bootstrap Carousel HTML structure and funny output [closed]
- How to remove custom style from source?
- Get all posts from categories
- How to add post classes?
- Extract and display user infromation on an automatically created page
- Why won’t this wpdb get_results query return results?
- Why doesn’t global $wp_query not get hooked?
- Is it legal to redefine wp_password_change_notification in a mu plugin?
- How can I assign separate stylesheets to different pages?
- Using multiple variables to assign categories to an array
- Show Custom Menu Name in WordPress 3
- Repeat a function with 24hrs gap for n number of days
- Add a custom WooCommerce settings tab with sections
- Checking page before applying image restrictions while uploading
- No more get_option(‘date_time’) in WordPress 5.5?
- How to update post content of all posts with tag?
- Create category after theme setup and modify the default one
- PHP error on local server install
- how to use 2 index.php file One for mobile and one for desktop
- Dynamic_sidebar load in string makeup
- Post Meta statement?
- Prepared DB Query from _POST array
- How to include non-users in wp-admin redirect?
- Add disclaimer before certain posts and pages
- auto metakey value on post tile
- Static home page ignored
- How do I routinely extract the thumbnail of the most recent post?
- Click to expand menu
- WP_Post is not from correct array
- calling a function from a class in your template
- Showing custom field contents without listing description
- Using ‘array’ method in wp_nav_menu causes it to disappear
- Custom single.php files for different post formats
- If I define a variable in header.php, how do I make it available to templates?
- How to add together (get the sum) a field from all author’s posts
- Remove /category/ from category (archive) page URLs (without using a plugin)
- JSON Object Value Show Undefine
- Redirect loop upon installation of my plugin
- Find owner of coupon
- WordPress wp_remote_request() – How to do async await in wordpress php?
- How Create Automatically Image jpg.webp from image .jpg without delete or change original images upload
- Need help with conditional logic for menus
- Advanced Custom Fields Auto Populating Field Values For Nested Repeater FIelds
- Hot to show custom post type taxonomies on archive page
- wordpress-plugin (widget) that performs a Neaby-search on the openstreetmap-endpoint: around x find y