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 Twenty Child
 Template:     twentytwenty
 Text Domain:  twentytwenty-child

 Theme URI:    http://example.com/twenty-fifteen-child/
 Description:  Twenty Twenty Child Theme
 Author:       John Doe
 Author URI:   http://example.com
 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 = 'twentytwenty-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen 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 *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.