How to load CSS on WordPress theme. Main CSS and RTL CSS
How to load CSS on WordPress theme. Main CSS and RTL CSS

awproject.net – This article will learn how to load css script on WordPress Theme oon teh beset way. First on your theme directory mak sure you have 2 file functions.php and style.css. Below are php script to load css file on your WordPress theme

1. Open functions.php add script below

if( ! function_exists( 'themeslug_load_scripts' ) ):
function themeslug_load_scripts() {
  wp_enqueue_style( 'themeslug-style', get_stylesheet_uri(), array(), '1.0' );
}
endif;
add_action( 'wp_enqueue_scripts', 'themeslug_load_scripts' );

2. If you want addional support of rtl css add code below, place after wp_enqueue_style script

wp_style_add_data( 'themeslug-style', 'rtl', 'replace' );

So, full code look like below

if( ! function_exists( 'themeslug_load_scripts' ) ):
function themeslug_load_scripts() {
  wp_enqueue_style( 'themeslug-style', get_stylesheet_uri(), array(), '1.0' );
  wp_style_add_data( 'themeslug-style', 'rtl', 'replace' );
}
endif;
add_action( 'wp_enqueue_scripts', 'themeslug_load_scripts' );

3. create css file named it style-rtl.css. On this file you can use same code on style.css and edit it for RTL purpose.

4. Make sure style id always same on this article style id is : themeslug-style

So? any question? leave comment below ,,, :mrgreen:

widhy980

Blogger, Web Developer & Traveler

Hi, I am from Indonesia, and i have more interest about website development. i have good skill on Codeigniter, Wordpress, HTML x CSS and Bootstrap. have a business? please contact me ... :D

You Might Also Like

Leave a Reply

Your email address will not be published. Required fields are marked *