Z
Z
zeaovede2021-10-12 23:23:03
css
zeaovede, 2021-10-12 23:23:03

What's wrong with these wordpress styles?

Styles are not applied on the WordPress site .

All paths are correct. There is another test site where everything works and there are no problems with it. Immediately I do not understand
There is a parent theme. There is a child: (the file is connected)

function my_scripts() {
    // Theme stylesheet.
    wp_enqueue_style('eloboost-child-style', get_stylesheet_directory_uri().'/style.css');
}
add_action( 'wp_enqueue_scripts', 'my_scripts' );


It would be fine if it didn’t work through the child, so it doesn’t see anything through the parent either.
Moreover, if you output through the body of the page or:
<link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_directory_uri(); ?>/style.css" media="all" />

then everything is connected, but this is WordPress, and I want to do everything according to the rules, because otherwise it is not necessary. Here is a test site .

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Thomas Laybe, 2021-10-13
@thomasLaybe

Try to create a css file in the wordpress root folder and copy the style.css file there
and include
function my_scripts() {
wp_enqueue_style('eloboost-child-style', get_stylesheet_directory_uri().'/css/style.css');
}
add_action( 'wp_enqueue_scripts', 'my_scripts' );

A
Artem Zolin, 2021-10-13
@artzolin

Correct connection of the style.css file

add_action( 'wp_enqueue_scripts', 'theme_scripts' );
function theme_scripts() {
  wp_enqueue_style( 'theme-style', get_stylesheet_uri(), array(), filemtime( get_theme_file_path( '/style.css' ) ) );
}

The code must be written in the parent theme. If a child theme is connected, then the function get_stylesheet_uri()will receive a link to the styles of the child theme, and not the parent theme
More on connecting scripts and styles here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question