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.

  • Thanks. Tried both those solutions but I get a HTTP ERROR 500 with both. Works fine on xampp though. – Steve Nov 5 '17 at 13:14
  • A 500 error is usually indicative of a PHP error. So finding the underlying PHP error would be most helpful. Otherwise there's no way to know exactly why it did not work. It could be something very simple. – jaswrks Nov 5 '17 at 13:18
  • Just commented out the code in the theme-options.php files and tested and they seem to be ok. Must be something in the functions.php file I guess. Tried so many ways to write that code but it just doesn't work for me. – Steve Nov 5 '17 at 13:31

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.