You can use wp_get_theme
:
<?php
$theme = wp_get_theme(); // gets the current theme
if ( 'Twenty Twelve' == $theme->name || 'Twenty Twelve' == $theme->parent_theme ) {
// if you're here Twenty Twelve is the active theme or is
// the current theme's parent theme
}
Or, you can simply check if a function in twentytwelve exists — which is likely less reliable; a plugin, or even another theme, could declare twentytwelve_setup
, for instance.
<?php
if ( function_exists( 'twentytwelve_setup' ) ) {
// Twenty Twelve is the current theme or the active theme's parent.
}
Related Posts:
- Plugin Deactivate Self on Activation Errors
- Activate plugins by a theme’s functions.php?
- Install theme as part of a plugin
- How To Activate Plugins via Code?
- how to get path to images in the uploads folder to be used in a plugin
- How can I create a bash install script for my WordPress sites setup (WP+plugins+theme)?
- How can I have two different urls for the same page that load two different templates?
- How to enable edit button in the theme’s customize UI?
- Automatically install wordpress plugin at theme activation
- Ship plugin with a custom theme
- How to solve a conflict between a plugin and a theme?
- WP Config for FTP credentials
- WordPress error – PHP Fatal error: Uncaught Error: Call to undefined function register_block_type_from_metadata()
- Which hook callback has priority if both plugin and theme use the same hook?
- Force wordpress to request for FTP Info on theme/plugin install/update
- WordPress register_activation_hook table creation not working
- Workflow and best practice for documentation [closed]
- Can I share predefined fonts from theme_support with a gutenberg component?
- How can I measure the performance of any WordPress Plugin or Theme?
- add_action in functions.php, do_action in plugin?
- WordPress 5 upgrade: until when is it safe to keep project running in 4.x?
- Installing WordPress only for a separate page – ‘mydomain.com/blog’
- Implement plugins as part of a theme
- ‘Customize’ button in admin bar for CSS
- Theme or Plugin: Where should I write my code?
- Is it possible to use WordPress as an online portfolio for text content? What kind of theme would I look for?
- Do I still need a theme to use page builders?
- Theme and plugin install or update display error in localhost
- Can I make a super plugin that also has a theme?
- Reduce Drop down Menu Width in WordPress
- Prevent WordPress installing plugins and themes via Admin
- Plugin Handle URL With Custom Theme
- How to block plugin activations with no known user or coming from unknown IP address range?
- Check for security updates
- Plugin-generated pages use Not Found or Pages Archive templates?
- Create custom registration form for WordPress Multisite
- Classified ad website : which solutions to use? [closed]
- Advanced Custom Field DatePicker [closed]
- All sites themes functions.php have been changed
- Finding the URL to be used to check if plugin is installed with a theme
- register_activation_hook in oop approach
- “No Add Button” for me to customize my WordPress with themes and pluggins
- How can I list all installed plugins/themes/versions from CLI/API?
- Why does my file_exist check fail?
- How to protect WordPress from security scanner [closed]
- how can I query all wordpress users of a blog
- Making that Admin Bar transparent or a blue color
- how to activate a plugin inside a theme
- There has been a critical error on your website – won’t fix no matter what
- Is it possible not to load theme on a specific page in wordpress?
- Override/ignore CSS from active theme as not to interfere with my custom CSS
- I receive taxonomy id
- To perform the requested action, WordPress needs to access your web > server
- How to extract a .wp-env.json or composer.json containing plugin versions from a production website?
- How to include files relative to a file’s directory
- Override css rules of a plugin within my own theme
- Blocking Plugin Css to load custom in template directory
- After a manual update, themes and plugins that were installed (and still in the directory) are not being seen
- Per theme plugins?
- My plugin does not install correctly if a previous version is still installed
- Is there existing plugins to “Click-to-Launch” embedded Flash / SWF content?
- Display WordPress comments before the plugins?
- Mobilepress fails to translate short codes
- uncaught TypeError: Cannot read properties of null (reading ‘classList’) custom plugin
- In Multisite Setups, how to update mass sections of sub-sites
- How to override any plugin file in the child theme
- Replace old theme that understand old css (vcex_icon_box css_animation)
- Mobile Menu and Mobile Sidebar missing
- custom fields not displaying on wordpress site
- elementor development – custom widget like an inner section widget
- How to run flush_rewrite_rules on activation after i register my custom post type using WordPress Boilerplate Plugin
- Different theme menu
- How to store a custom theme and update it on other installations
- How to get a post views count using ‘WordPress popular posts’ plugin
- Can’t add new plugin or themes on a wordpress multisite network from the primary site as administrator. Error: ERR_TOO_MANY_REDIRECTS
- How to prevent redoing get_posts queries and make results available to other scripts?
- Is it possible to disable a theme programmatically?
- Google trying to index child theme files
- In the WordPress API is there a way to set the width of the post/page container
- How can I add a custom checkbox / radio button on the admin theme options to display a CSS or other?
- wp_login_form() ignoring login_form action hook
- What Are the Advantages of Using an mu-plugin
- How to fix On “An unexpected error occurred” message when I click on Add new theme or plugin?
- How to display post by date written (1974) and not date published (today)?
- API calls on plugin activation or init?
- Things that saved lose when logout
- Automatic updates of plugins and themes outside of wordpress.org
- Theme specific plugin, how?
- Different plugins activated online and offline
- Run WP inside a other Site without using frames
- Breadcrumb is not generating the correct post page url
- why i cannot see some plugins while they are enabled on network admin page?
- Theme causing SSL break on chrome
- Why does theme need woocommerce to show images / content on front page?
- My Blog page ( posts page ) theme isn’t changing with the new theme [closed]
- How to create an Info Box on WordPress [closed]
- How to make content as required in custom post type?
- Any plugin installation and update overwrite current theme
- Problem on a wordpress website with a plugin [closed]
- What’s the best way to update my WordPress theme to Elementor?