Skip to content

Instantly share code, notes, and snippets.

@ChrisHardie
Last active August 21, 2018 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisHardie/3c546900783fcb8751f9633792a7f90e to your computer and use it in GitHub Desktop.
Save ChrisHardie/3c546900783fcb8751f9633792a7f90e to your computer and use it in GitHub Desktop.
Example function to load plugins within wp-content/themes/mytheme/plugins/
/**
* Add in-theme plugins
*/
function my_theme_plugins() {
$plugins_to_include = array(
'wordpress-fieldmanager/fieldmanager.php',
);
if ( count( $plugins_to_include ) ) {
$theme_plugin_dir = get_stylesheet_directory() . '/plugins/';
foreach ( $plugins_to_include as $plugin ) {
if ( file_exists( $theme_plugin_dir . $plugin ) ) {
include_once( $theme_plugin_dir . $plugin );
}
}
}
}
add_action( 'after_setup_theme', 'my_theme_plugins' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment