You can do it easier and without polluting the global namespace: get_option('template');
gives you the (parent) themes name. If you want the child themes name, use get_current_theme();
.
You could also use a constant across your theme files: define( 'YOUR_PREFIX-THEME_NAME', get_current_theme() );
Related Posts:
- Best way of passing PHP variable between partials?
- Custom page with variables in url. Nice url with add_rewrite_rule
- How Can I Access a PHP Variable in Another PHP Function
- Is it better to assign functions like get_the_id() to a variable if it’s used multiple times?
- Assigning WP functions which echo to PHP variables
- Passing values from a widget to a function within a plugin
- How to pass variables from a function in functions.php to an other one
- Define PHP variable from a seperate API if statement
- problem loading stylesheets to wp_head dynamically
- Undefined variable error in new function
- add_menu_page() with variable function
- Do I Need to Prefix Variables Inside Functions?
- Updating custom query var with multiple values
- Change Page Title
- get variables data from functions.php to template wordpress (without global variables)
- Getting value of variable from functions.php and debugging it
- Pass post ID from archive template to functions file
- How to access custom class methods from any include without using global
- Using a variable in name of dynamically-called helper function
- Add array of category IDs to global variable?
- Setting a cookie in functions.php and it gets deleted when working on an other function
- getExcerpt: Make ellipsis appear only if character limit is reached
- Using Output from one Function and calling it into another
- How do I access variables outside a function [closed]
- Trying to get this function to show below the content
- add variable to actions/functions across different files (woocommerce)
- Adding a second email address to a completed order in WooCommerce [closed]
- What is the difference between get_page_link and get_permalink functions?
- Possible to search by author name with default WordPress search function?
- Breadcrumbs showing Parent and Child Pages
- Influence of WordPress functions on site speed
- Is it possible to override this function/class in a child theme?
- mysql custom wp query
- TinyMCE custom stylesheets for different post types
- When new user register then add new user role
- Display random text from a file with the WP built-in AJAX API
- Remove bulk actions based on user role or capabilities
- Set first oembed in post to a global variable or function
- Adding extra SVGs to TwentyNineteen child theme using class TwentyNineteen_SVG_Icons
- wp_delete_attachment
- WordPress registration and contact form 7 [closed]
- Is It wrong to use oop approach on functions.php?
- How to preserve edits to Name or Slug of term when using wp_update_term on save?
- Woocommerce checkout field maxlength, make input number field only (postcode)
- My simple custom shortcode is not longer working (possibly due to upgrade to WordPress 4.4 ?)
- PHP files included in functions.php don’t seem to work
- Register and enqueue style.css custom theme
- Where do I add html code to the menu div?
- Add function to every post?
- WordPress shortcode attributes for database SELECT?
- How to get membership level for specific user email
- Understanding and altering the structure of posted images
- What do the schemes login, login_post, admin, and relative mean?
- Backstretch.js and thumbnail sizes to reduce loading time
- How to stop twenty fifteen theme from cropping featured images?
- Update user meta of author when post content is viewed
- Don’t display html if function returns nothing
- Load custom css in functions.php causing library issue
- In jquery use php variable to execute an enqueued jquery file
- How to stop media_sideload_image from running when deleting a post?
- I want to display latest post in marquee [closed]
- Add php code to wp_print_scripts?
- How to get an attachment id from a filename
- Remove ‘page-numbers’ class from prev and next tags
- How can I set the SRC URL of the custom logo image?
- The Capability to choose post/page template
- How to make custom comment fields required
- Overide Variable in Child Theme
- How do I register a new settings page? [closed]
- Include Jquery libraries in wordpress theme?
- WooCommerce -> wc_enqueue_js not working [closed]
- Use existing image sizes for WooCommerce
- Retrieve First Image Function
- User meta and public function security
- Any adverse effects of adding apply_filters to a function?
- How can I remove page titles without removing the link in the navigation bar in twentyeleven?
- Display ACF category image on archive and single template files
- How to get taxonomy tree ids without running expensive loops
- Change WooCommerce Payment Options From Radio Buttons to Dropdown Menu
- WordPress Function Assistance with Loop
- Using get_terms for custom taxonomy in functions.php
- Add Change role button for list of user in an event
- Child theme remove parent filter in functions
- Set URL Parameter Post Layout As Default
- Exclude admins from query get posts
- Classic TinyMCE messing up only Contributor’s HTML
- How to add publish/draft button in Admin Post Lists
- Show users last read posts for each user?
- Woocommerce – change order status from on-hold to pending payment
- Disable links to images only if link is an image
- How do I integrate my Child Theme into a Custom Template?
- Sending Messages Back to the Template After Processing?
- Shortcode to eliminate and replace with
- How can I see a varibles value when my plugin runs?
- Why are some custom javascript files working but some are not
- using enqueue_script in a shortcode isn’t working
- Filter to strip unnecessary attributes
- Will my WordPress site become vulnerable after adding this functions which allows more HTML tags for subscribers?
- get_post_class() not working well
- woocommerce_sort_product_tabs() expects an array