How to load style.css after fonts.php in wordpress?

I develop a website locally in WordPress and then upload it to a temporary dev server to periodically show my progress to management.

Problem : When I upload everything to the server, I noticed that the styles in my .css style are overridden by those specified in the fonts.php file. This is my first time using the Wordpress platform. I do not know why, but this is not the case when I post it locally. As you see in the picture, fonts.php is declared after style.css. Picture:enter image description here

What I tried : I burst into wordpress files to find a way to declare fonts.php first and then style.css later so that style.css overrides fonts.php. I found this file in wp-includes / theme.php, where I found the declared style.css, but could not find for fonts.php. It was a dead end.

Does anyone know how to do this?

+4
source share
3 answers

Thanks Sushil for the message. This is useful if I need to add a css file from outside, but did not solve my problem, which attempted to download fonts.php before.

I found a simple solution. I moved all the css that I wanted to override to fonts.php in the adaptive.css file, which always loads after the fonts.php file.

+1
source
// Load the theme stylesheets
function theme_styles()  
{ 

    // Example of loading a jQuery slideshow plugin just on the homepage
    wp_register_style( 'flexslider', get_template_directory_uri() . '/css/flexslider.css' );

    // Load all of the styles that need to appear on all pages
    wp_enqueue_style( 'main', get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'custom', get_template_directory_uri() . '/css/custom.css' );

    // Conditionally load the FlexSlider CSS on the homepage
    if(is_page('home')) {
        wp_enqueue_style('flexslider');
    }

}
add_action('wp_enqueue_scripts', 'theme_styles');
+1
source

CSS Wordpress wp_enqueue_style()

`<?php wp_head(); ?>` 

, wp_head(). .

, wp_head(); header.php.

functions.php , index.php. functions.php , wp_register_script, wp_enqueue_style.

, Bootstrap.

`<?php
function add_stylesheet() {
wp_register_style('bootstrap.min',get_template_directory_uri() . 
'/css/bootstrap.min.css');
wp_enqueue_style( 'bootstrap.min' );
}
add_action( 'wp_enqueue_scripts', 'add_stylesheet' );
?>`

, ?

add_stylesheet() - , .

WordPress wp_register_style. 5

`$handle, $src, $deps, $ver, and $in_footer`

After registering our style, we can call it using the WordPress function wp_enqueue_style. That is, this method may seem complicated at first, but it is the preferred method of invoking style sheets in WordPress.

+1
source

All Articles