How can I stop the hook from breaking the login/logout function?

Steve asked
functions hooks theme-options

I added this code to my functions file so there are different theme options depending on whether or not a plugin is activated.

function theme_options_select() {
if( is_plugin_active( 'gallery-nails/gallery-nails.php' )) {
    require get_template_directory() . '/inc/theme-options/nails/theme-options.php';
else {
    require get_template_directory() . '/inc/theme-options/default/theme-options.php';
add_action( 'wp_loaded', 'theme_options_select' );

I’ve tried plugin_loaded and setup_theme but then the theme options are inaccessible. init works as well but also breaks the login.

Anyone know how to fix this?


If this is in functions.php, then you don’t need a hook for this at all, because the functions.php file is loaded right where you want it. So just unwrap this and move it out of a function call altogether; i.e., still in your functions.php, but not attached to any specific hook.

Or, use the after_setup_theme hook if you want to delay it slightly.

Share This
Posted in: