• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

How do you create custom.css for a child theme?

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › How do you create custom.css for a child theme?

This topic is: not resolved
  • This topic has 6 replies, 3 voices, and was last updated 9 years, 11 months ago by hp.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • May 16, 2013 at 9:31 am #41204
    dev
    Participant

    Two questions:

    1. How do I make a custom.css file for a Gen. child theme? Which is the "best practice":

    http://www.briangardner.com/code/load-custom-style-sheet/
    (Looks like this also deletes the "style.css"? Don't want that do we?

    <?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', CHILD_URL . '/custom.css', array(), PARENT_THEME_VERSION );
    }
     
    // Replace default style sheet
    add_filter( 'stylesheet_uri', 'custom_replace_default_style_sheet', 10, 2 );
    function custom_replace_default_style_sheet() {
    	return CHILD_URL . '/custom.css';
    }
    

    http://www.petersenmediagroup.com/code/custom-css/

    // Add custom.css file in functions.php
    add_action('wp_head', 'add_customcss');
    add_customcss( ) {
    $pmg_css_link = ' ';
    echo $pmg_css_link;
    }
    

    Custom CSS file???

    add_action( 'wp_enqueue_scripts', 'enqueue_custom_stylesheet' );
    function enqueue_custom_stylesheet() {
    wp_register_style( 'custom-css', get_stylesheet_directory_uri() . '/custom.css' );
    wp_enqueue_style( 'custom-css' );
    }
    

    2. I'm trying to "update-proof" a child theme as I have a ton of CSS overrides in one theme I don't want "lost" if the vendor comes out with a new version should WP require it. Is this even a necessary practice in Gen-world?

    Thanks.

    May 19, 2013 at 3:10 pm #41673
    dev
    Participant

    I am surprised that after three days no one answered this. Maybe custom style sheets are just not done in Genesis land?

    Anyone?

    July 3, 2013 at 4:27 am #48946
    hp
    Member

    I raised a ticket before in StudioPress helpdesk about custom.css too. Many other frameworks include that option already. Just create custom.css (or some other name that framework can define in its document), then your WordPress installation will automatically recognize and use settings there with higher priority. I am not sure why StudioPress doesn't have that useful feature. When I asked, they just replied that it might be appearing in the future.

    Back to your question, I believe the 1st and 3rd ways are the same method. And wp_enqueue_style() is preferred. In case you want to use gzip or minify option, it will use wp_enqueue_scripts structures, beside the benefit that is making sure to load script once.

    July 3, 2013 at 8:11 am #48958
    dev
    Participant

    The third way works great.

    Thank you so much for taking the time to research this and answer my inquiry.

    July 3, 2013 at 10:59 am #49012
    Doak Heggeness
    Member

    You also have to load your custom.css after the child theme styles.css for it to take precedence. I am unclear why you need one regarding your vendor?


    Doak Heggeness, WordPress Development | Website

    July 3, 2013 at 11:33 am #49021
    dev
    Participant

    You also have to load your custom.css after the child theme styles.css for it to take precedence. I am unclear why you need one regarding your vendor?

    Good point. The '3rd method' above does load the custom.css after the style.css.

    As for why I'm bringing up the topic.. my thinking (logical progression) is this:

    - I've been involved in IT systems work for 35 years (stated in 1973 with EDS)
    - WP 3.6 is due out soon
    - Gen 2.x is due out soon
    - My experience tells me that things will break
    - Some SP and community themes will (might) have to be changed
    - The theme updates will 'wipe out' all changes made in the current theme's CSS.
    - Ergo... perhaps it is best to take out all CSS overrides that are now at end of style.css and put them in custom.css

    Maybe above won't happen, but like other professional web design shops in the Genesis community, clients expect us to anticipate problems and have solutions to them before they occur.

    http://www.NewMediaWebsiteDesign.com

    July 3, 2013 at 4:31 pm #49080
    hp
    Member

    Again, that's why I raised a ticket with StudioPress. It doesn't take much time to write a function for checking and loading custom.css if it's existed. Hope they have it in Genesis 2.0 when it's out. It will help to save time of all Genesis coders.

  • Author
    Posts
Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble