style.css not working in wordpress
Add stylesheet other than style.css , open function.php and add the following code.
add_action( 'wp_enqueue_scripts', 'theme_name_scripts' ); function theme_name_scripts() < wp_enqueue_style( 'style-name', get_stylesheet_uri() . "/css/bootstrap.css" ); wp_enqueue_style( 'style-name', get_stylesheet_uri() . "/css/bootstrap-responsive.css" ); >
Add the style.css file using thins:
Add the following to your functions.php, it should work.
function EnqueueMyStyles() < wp_enqueue_style('my-custom-style', get_template_directory_uri() . '/css/my-custom-style.css', false, '20150320'); wp_enqueue_style('my-google-fonts', '//fonts.googleapis.com/css?family=PT+Serif+Caption:400,400italic', false, '20150320'); wp_enqueue_style('my-main-style', get_stylesheet_uri(), false, '20150320'); >> add_action('wp_enqueue_scripts', 'EnqueueMyStyles');
For my case, i had not linked CSS. So i solved it by doing the following:
- I created a file header.php this file had my html code and inside of this file, instead of manually including the css file using link , i called a php function wp_head(); which helps wordpress to take control of my head section.
After that i had to create another new file in the themes folder called functions.php and linked style.css in this file using the following code.
add_action( 'wp_enqueue_scripts', 'files' ); ?>
Open function.php file and past the following code.
add_action( 'wp_enqueue_scripts', 'theme_name_scripts' ); function theme_name_scripts() < wp_enqueue_style( 'style-name1', get_stylesheet_uri() . "/css/style.css" ); wp_enqueue_style( 'style-name2', get_stylesheet_uri() . "/css/bootstrap.css" ); >
I had the same problem, but I fixed it by looking carefully in my code. This is what I wrote before:
rel="stylesheet" type="text/css" media="all" />
As well as the following code helped me solved the problem:
Can you see the difference? Comment below if you have any questions.
when you also have 2 site URLs or home URLs in your plugins or CSS when you look it up in the inspection on chrome or some browser. And opening this in a new tab (btw this should not be accessible)::
«/» without the «» in your localhost or whatever > phpmyadmin > database (of WordPress) > wp_options >> «siteurl» and «home» in option_value
I mean you can always try this. Easy to go back if it does not work. I did not read your problem. But this was the fix I was looking for and found the solution my self. just remember what was there in the first place.
Replace template_url with template_directory in bloginfo and all done like:
/css/bootstrap.css" /> /style.css" />
In functions.php add this code it will link style.css file to your WordPress theme
function load_scripts() < wp_enqueue_style( 'stylecss', get_stylesheet_uri() ); >add_action('wp_enqueue_scripts', 'load_scripts' );
Linked
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.27.43548
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
WordPress admin not loading css/js
I’m having a problem with the admin on a WordPress site. I’ve scoured the interwebs and seen lots of other people with the same problem, but no definite solution. The admin is showing like this: And when I inspect it, I get a 500 (Internal Server Error) on both load-styles.php and load-scripts.php Anyone know what’s up, and how to rectify?
I had a similar problem, managed to fix it by hitting the Reinstall Now button on the Updates page under «If you need to re-install version 5.3.2–en_AU, you can do so here:»
10 Answers 10
In wp-config.php before require_once add below code into file :
define('CONCATENATE_SCRIPTS', false);
Confirmed. This one is the one that works. The other answer below kind of works too but not nearly as well as this one. Deleting browser cache and everything, that was useless. Just as another note — if you installed wordpress using digitalocean, you have to go to cd /var/www/html to find your wp-config.php file. Took me a stupid amount of time to find it.
This worked for me and worked only before «require once», I tried before using other thread here and put it under, and did not work.
The only thing that worked for me. Spent 4 hours trying to fix it. Nothing else worked (deleting all plugins and themes, disabling cache). Thank you!
Just to keep everything in one answer, this worked for me:
define('FORCE_SSL_LOGIN', true); define('FORCE_SSL_ADMIN', true); define( 'CONCATENATE_SCRIPTS', false ); define( 'SCRIPT_DEBUG', true );
After page refreshing and it looks OK, maybe after re-login, set SCRIPT_DEBUG to false.
Don’t forget about those last two settings if you’re using a plugins for debugging or site optimization — though such plugins might override those settings.
This works except using localhost leads to no valid ssl keys. And commenting out force_ssl leads to prefect working scenario.
Also had similar issues that affected custom fields and elementor plugins only after upgrade to the latest version of wordpress (5.5.1). It was affected by the theme used (not developed by me). Switching between a default theme fixed the problem. There were no errors displayed or logged. Also project in live server without xdebug or other means of debugging except plain old way.
A simple change made, were there is no more ‘type=»text/css»‘ in the tag and the use of a pregmatch filter was the problem 🙂
preg_match_all("!!", $input, $matches);
preg_match_all("!!", $input, $matches);
Found e perfect inspiration here enter link description here.
style.css not applying on wordpress theme?
I am having this problem where style.css is not being applied to WordPress theme.
Please note that I have copied my custom stylesheet replacing the default one. So when I inspect element no css is appearing in developer tools. What could be causing this?
I am using Twentyseventeen theme. Edit:Found the solution actually I was replacing the entire header with my custom header code due to which wp_head() was overwritten which I suppose calls all the css and js in header.
Even though you have partially solved the issue, you should refer to the answers below for info on how to add custom css. Doing it the way you have described is not a good idea.
Is the stylesheet appearing in the source-code? Does a stylesheet exist at that URL or does it throw a 404 when you visit that url?
4 Answers 4
You should not replace the CSS file. When updating the theme, it will get replaced with the original and you will lose your customizations.
What you should do is creating a child theme. In a child theme you can make your customizations, without any trouble when updating the default theme.
Edit: Since a previous version of WordPress there is the possibility to add custom CSS to a theme. But I’m not sure how reliable this will be in the future. You can try it, but I still recommend a child theme.
You shouldn’t replace the themes CSS file or add CSS to the included CSS file(S) for the following reasons:
- WordPress uses the default style.css file purely for getting info about the theme
- The file will get overwritten by any theme updates
However, you should create your own css file and then tell WordPress to load that file. You can do this by adding the following code to your *theme’s functions file or by creating a custom plugin for doing any customisations such as this.
wp_enqueue_style( 'style', get_stylesheet_uri() );
*Note any customisations added to a themes functions file would also get overridden by any updates to the theme.
You should not replace entire wp header with your custom header. You can place your custom header related css and js files etc. before wp_head() hook being called. And also check the below things.
1. Check weather the below line of code is there or not in your theme function.php file
wp_enqueue_style( ‘twentyseventeen-style’, get_stylesheet_uri() );
2. Check the your theme stylesheet is having comment section or not. It should be like the below..
WordPress does not properly display CSS file
I have a crazy problem happening and it is blowing my mind. I installed WordPress on my Localhost and began developing. I modified the standard twenty twelve theme and add custom HTML and CSS to the whole site (4 or 5 pages.) The site shows up great on my local machine (Mac OSX — Safari 6.0.5, Firefox 23.0. Chrome 29.0). I transferred my site to my live host (under GoDaddy) and I migrated the database by dumping it and then importing it. Now I can pull my site up under both my localhost and by going to the live host URL and the site looks exactly like it should. However, when I crosscheck the CSS via sites like (browsershots.org and browserstack) the site look terrible. Its almost like the main style.css file is not being linked properly. These browser check sites shows the site in ruins on all operating systems and all browsers. Still though when I bring the site up on my personal machine it looks just as it should. My client pulled the site up from their machine and it looked in ruins, just as the css checking sites depicted it. I have cleared my browser cache thinking I may be reloading a cached version of the site (giving me false hope that it looks good) however it still appears just like it should while viewing the remote version through my local machine. Side note:All elements of the page appear to be loading fine. The menu bar is there. The text and content is there. It’s just not styled. Does anyone have any idea what may be going on?
4 Answers 4
The site is trying to serve the files from your localhost.
When your domain name or URLs change — i.e. from http://example.com/blog to http://example.com, or http://example.com to http://example.net — there are additional concerns. The files and database can be moved, however references to the old domain name or location will remain in the database, and that can cause issues with links or theme display. You need to change the site urls in your database before moving to a new host.
You will need to change those hardcoded urls, either by manually searching and replacing them in your database, or using this script.