I want to style the WordPress admin area.
For this purpose, I have copied the following code in the function file and started styling it:
function custom_css()
{ echo '<style>
.widefat {
width: 1700px !important;
max-width: 1700px !important;
}
</style>'; }
add_action('admin_head','custom_css');
this way, the function file becomes very crowded, and that’s why I want to style it in a separate CSS file; How can I enter the link of my style.css file in the code above?
I have used this code but it did not work:
{ echo include ("/style.css"); }
3
Answers
I found the answer to my question. The answer is as follows:
WordPress theme’s css files are responsible for the styling and look of the website. They are located in the
/wp-content/themes/
directory. The css files are usually namedstyle.css
, there are some additional options you can try:Inside
style.css
use the@import
at-rule to link to another file (if it is hosted externally).@import url("//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css");
Edit the
header.php
theme to link to an external stylesheet.<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
In order to link a CSS file in WordPress header, you need to first enqueue the file using
wp_enqueue_scripts
from functions.php After that, you can then link to it usingget_stylesheet_uri
or enqueue file pointing to your external css url