0

I've been searching around for a long while now. There seem to be plugins available for this, but hardly anything that is current.

Many of the plugins I have already tried do not work correctly with WordPress 3.8+

My needs are basic. All I want to do is load another theme if I am logged in as an admin, so that I see a different front-end.

Thanks, Michael.

1 Answer 1

3

You can use the filter stylesheet:

<?php add_filter( 'stylesheet', 'wpse149620_stylesheet' );

function wpse149620_stylesheet( $stylesheet ) {
    if ( ! is_admin() && current_user_can( 'administrator' ) ) {
        $stylesheet = 'admin-theme';
    }

    return $stylesheet;
} ?>

However, this must be loaded before the first time the "current theme" is requested, which can only be done (without editing core) by putting this in a Must Use Plugin.

Create a directory called 'mu-plugins' in 'wp-content' and insert this code into a PHP file. WordPress will pick this up automatically. Make sure there are no spaces, line breaks or output before the PHP code to avoid a fatal error.

2
  • What's the significance of wpse149620_stylesheet? Can that be anything? Jun 14, 2014 at 14:57
  • 1
    That's the function name.
    – engelen
    Jun 14, 2014 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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