Skip to content

Instantly share code, notes, and snippets.

@ChrisHardie
Last active Aug 21, 2018
Embed
What would you like to do?
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