简体   繁体   中英

WordPress Child Theme for specific roles

I'd like to restrict a child theme to only being visible to me, the admin, for development purposes. Then I can make changes, upload and view them live and on the site without other people seeing those unfinished changes. Once I'm done, I take the affected files and move them to the Parent Theme's folder to make the changes visible to everyone.

Is this possible with some kind of script through functions.php?

You would probably want to create a development environment on a subdomain, but if you are restricted by this, you will want to enqueue the style only when you are logged in.

In style.css (change twenty fourteen to match your current theme)

/*
Theme Name:   Twenty Fourteen Child
Theme URI:    http://example.com/twenty-fourteen-child/
Template:     twentyfourteen
*/

@import url("../twentyfourteen/style.css");

In header.php

if ( is_user_logged_in() ) {
    if ( $user_id = YOUR_USER_ID ) {
        wp_register_style('YOUR_STYLE', get_stylesheet_directory_uri() . 'PATH.css');
        wp_enqueue_style('YOUR_STYLE');
    }
}

This should be the general idea of what you want to do. Comment if you have any questions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM