• Posted: 2012-05-01
  • Author: Stan Duncan
  • Tags:

Theme Specific Conditional

  1.  
  2.  
  3.  
  4.  
  5.  
<?php
	if (get_current_theme() == 'Theme Name') {
		echo '# code...';
	}
?>

Instructions:

This can be used for code for a specific theme only. I had to use something similar to this when developing a site that used a mobile theme switch for a plugin I only wanted on the desktop site and not on the mobile site.

Note: Can only be used in conjunction with “theme switching plugins” if the desired “theme specific plugin” comes AFTER the “theme switch plugin” in order of execution.


Share this snippet

If you like this snippet, share it with friends!