• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
  • Skip to user navigation

PopWP

WordPress and Genesis Tutorials

  • Get Started
  • About
  • Archive
  • Services
  • Membership
  • My Account

How to add Additional stylesheet in Genesis child theme

Last Updated on July 29, 2018 Favorited: 1 times

Additional stylesheets are required and should recommend to design a child theme. You can even add an additional stylesheet for different contents separately.

Method 1.

Step 1. Create a file custom.css under child theme and place some stylesheet info if you want.

/*
	Theme Name: Custom Theme CSS
	Theme URI: https://example.com/
	Description: This is the custom css created for the Example.
	Author: Your Name
	Author URI: https://www.yourname.com/

	Version: 1.0.0

	Tags: Custom, addiitonal

	Template: genesis

	License: GPL-2.0+
	License URI: http://www.gnu.org/licenses/gpl-2.0.html

*/

/* Start writing Custom CSS
---------------------------------------------------------------- */

Step 2. Once, the custom CSS file is created, it is time to show it on site. Add this code in functions.php

//* Load custom style sheet
add_action( 'wp_enqueue_scripts', 'load_custom_style_sheet' );
function load_custom_style_sheet() {
	wp_enqueue_style( 'custom-stylesheet', get_stylesheet_directory_uri() . '/custom.css', array(), '1.0.0', 'all' );
}

 

Method 2.

You can simply show the CSS file using one line of code

//* Display Custom Style CSS
	wp_enqueue_style( 'custom-style', get_stylesheet_directory_uri() . '/custom.css' );

Note:- This will not overwrite the CSS, it simply enqueue the file. Please use the method 1 to ensure that your custom file is overwriting your CSS.

Method 2 works well when you have had to show additional features without interfering the default style.css file.

Like you have to show different features and the best possible way to do is to use a different file name for each feature.

Additional:-

If you want to add CSS file in other folder you can create a folder ‘css’ under public_html and create custom.css file and use this snippet in functions.php

//* Load custom style sheet
add_action( 'wp_enqueue_scripts', 'custom_load_custom_style_sheet' );
function custom_load_custom_style_sheet() {
	wp_enqueue_style( 'custom-stylesheet', '/css/custom.css', array(), '1.0.0' );
}
//* Load custom style sheet
add_action( 'wp_enqueue_scripts', 'load_custom_style_sheet', 100 );
function load_custom_style_sheet() {
	wp_enqueue_style( 'custom-stylesheet', get_stylesheet_directory_uri() . '/custom.css', array(), CHILD_THEME_VERSION, 'all' );
}

Note:- Make sure to check the path of the file in the source and the changes you have added.

Here How you can load stylesheet conditionally.

Reference:

wp_enqueue_style()

 

Related Posts

  • Featured Post Widgets in Columns
  • Site Inner with container background in Genesis Sample
  • Add Logo Between Site Title Area in Genesis
  • Expanding Search Box in Genesis
  • Add Custom Class to the Site Title in Genesis

Categories: Free Content, Genesis Tutorials, WordPress Tutorials Tags: CSS, Stylesheet

Reader Interactions

Primary Sidebar

Search

WPEngine WordPress Hosting, Perfected.

Hosting You are looking for?.
Perfect solution for small business to global enterprise.

Learn more

StudioPress Genesis Theme Framework

The No.1 Theme Provider.
Creative, SEO rich Theme for all niche projects.

Learn more

Categories

  • Free Content
  • Genesis Tutorials
  • Premium Content
  • Snippets
  • What's New?
  • WordPress Tutorials

Tag Cloud

Archive Background Section blog canvas menu center logo columns conditional tags CSS CSS Grid custom Customizer custom post type Custom Post Types custom template Custom Widget effect eNews Extended Featured Image front-page Genesis Genesis Sample header right hero section Image Background js layout left menu Logo menu Navigation Menu newsletter post page related posts responsive menu search search widget Shrinking Logo site header slide in-out Stylesheet Template Utility Bar Video Background widgets WordPress

Built with Genesis Framework + WordPress by Aryan Raj

  • Contact
  • FAQ
  • Disclaimer
  • Privacy Policy
  • Copyright Policy
  • Terms of Service