简体   繁体   中英

Wordpress child theme for second installation

We have WordPress installed for our main website with it's own theme. I now want to install another WordPress in a sub-folder where I want to use the main website's theme there.
So I've made a new theme which includes 3 files:

index.php
style.css
functions.php

I'm referring to the main website theme files (header.php for example) in the new installation index.php file:

    <?php
//Checking if file exist
if ( file_exists( get_stylesheet_directory() . '/../../../../wp-content/themes/First/header.php') ) {
    //Require file if it exist, 
    require_once( get_stylesheet_directory() . '/../../../../wp-content/themes/First/header.php' )
} else {
    /* Echo something if file doesn't exist, if the message wasn't displayed and you still get 500 error then there's some wrong on the php file above*/
    _e('File not found');
}
?>

However, this returns 500 error, anyways, Can I do something like this ? to use another WordPress installation themes on a new installation of WordPress in a folder?

Please use register_theme_directory() function and use absolute paths.

Please also see this: https://wordpress.stackexchange.com/questions/83102/how-do-you-change-the-theme-location

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