Addiction Dependent Theme

I am trying to create a child theme. The parent theme has style.css and that's it, and I looked at the function wp_enqueue_style()and it says that you can include dependencies. This means that themes style.csscan be active, and in my child theme, if I specify the same rule in my .css style, it should overwrite it.

But addiction is an array of pens. How to find these descriptors?

wp_enqueue_style( 'mytheme-style', get_stylesheet_directory_uri().'/style.css', array('main_css') );

I tried with this, but it only loads the style. css from the child thread, not from the parent.

Where can I find these descriptors?

EDIT:

I found code for playing descriptors and scripts:

function wpa54064_inspect_scripts() {
    global $wp_scripts;
    foreach( $wp_scripts->queue as $handle ) :
        echo $handle,' ';
    endforeach;
}
add_action( 'wp_print_scripts', 'wpa54064_inspect_scripts' );

function wpa54064_inspect_style() {
    global $wp_styles;
    foreach( $wp_styles->queue as $handle ) :
        echo $handle,' ';
    endforeach;
}
add_action( 'wp_print_scripts', 'wpa54064_inspect_style' );

But it still does not work as I thought.

+4
source share
1 answer

get_stylesheet_directory_uri() URL- , .

style.css , get_template_directory_uri() .

:

wp_enqueue_style( 'mytheme-style', get_template_directory_uri() . '/style.css', array('main_css') );

, ( functions.php):

function wpse_load_styles() {
    wp_enqueue_style( 'parent-styles', get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'mytheme', get_stylesheet_uri(), array( 'parent-styles' ) );
}
add_action( 'wp_enqueue_scripts', 'wpse_load_styles' );
+1

Source: https://habr.com/ru/post/1568327/


All Articles