8. Jun 2020 |

WordPress child teema tegemine

Taaskord märkmed endale. Kuna dokumentatsioon on üsna segane.

See on style.css, mille paned tühja alamteema kasuta.

Theme Name: unikaalne nimi sinu teemale
Template:
 on teema kausta nimi
Text Domain: on alamteema kausta nimi.
Kõik muu pane nii nagu ise tahad.

/*
 Theme Name:   Twenty Sixteen Child
 Template:     twentysixteen
 Text Domain:  twentysixteen-child

 Theme URI:    https://that.ee/
 Description:  Twenty Sixteen Child
 Author:       John Doe
 Author URI:   https://that.ee
 Version:      1.0.0
 License:      GNU General Public License v2 or later
 License URI:  http://www.gnu.org/licenses/gpl-2.0.html
 Tags:         light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
*/

See on functions.php

Vaata, et 5. real olev $parenthandle läheks kokku sellega, mis on ülemteema teema functions.php real, kus on get_stylesheet_uri.

<?php

add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
    $parenthandle = 'twentysixteen-style'; // This is 'twentysixteen-style' for the Twenty Sixteen theme.
    $theme = wp_get_theme();
    wp_enqueue_style( $parenthandle, get_template_directory_uri() . '/style.css', 
        array(),  // if the parent theme code has a dependency, copy it to here
        $theme->parent()->get('Version')
    );
    wp_enqueue_style( 'child-style', get_stylesheet_uri(),
        array( $parenthandle ),
        $theme->get('Version') // this only works if you have Version in the style header
    );
}

Muud polegi. Kõik peaks töötama.

Leave a Reply

Your email address will not be published. Required fields are marked *