theme style is applied on the dhasboard rather than the website
-
26-04-2021 - |
سؤال
I am creating a new theme, I created a new directory called mytheme and created three files directly inside the directory where the content is as follow:
index.php
<?php echo "hellow world"; ?>
style.css
/*
Theme Name: mytheme
*/
body {background: red;}
functions.php
<?php
wp_enqueue_style( 'style', get_stylesheet_uri() );
?>
the problem: the dashboard is colored in red.
expectations: the website itself to be colored in red.
Edit:
the solution marked is only half the answer.
index.php needs to have headers initiated otherwise it wont work
index.php is now:
<?php
wp_header();
echo "hellow world";
?>
المحلول
You need to enqueue your stylesheets and script to wp_enqueue_scripts
hook.
In your functions.php try
function enqueue_scripts_cp() {
wp_enqueue_style( 'style', get_stylesheet_uri() );
}
add_action( 'wp_enqueue_scripts', 'enqueue_scripts_cp' );
لا تنتمي إلى wordpress.stackexchange