Add custom.css and or font with code or header link. Best practice?

Community Forums Forums General Discussion Add custom.css and or font with code or header link. Best practice?

This topic is: resolved

Tagged: 

This topic contains 4 replies, has 2 voices, and was last updated by  dev 5 months, 2 weeks ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #95061

    dev
    Participant
    Post count: 453

    I know some folks say that a custom.css is not needed with Genesis child themes, but we use them anyway for reasons too involved to discuss here.

    We have always used the link in the Genesis Theme Options “header” box:

    [html]
    <link rel=’stylesheet’ id=’optimal-theme-css’ href=’http://xxxxxx/custom.css?ver=1.0.0′ type=’text/css’ media=’all’ />
    [/html]

    but I’m now seeing people suggesting we use code in functions.php like this:

    [php]
    add_action( ‘wp_enqueue_scripts’, ‘maj_load_custom_css’ );
    function maj_load_custom_css() {
    wp_enqueue_style(
    ‘custom-css’,
    CHILD_URL . ‘/custom.css’,
    array(),
    PARENT_THEME_VERSION
    );
    }
    [/php]

    Is one way any more efficient than the other? What is the ‘best practice’ now.

    Same kind of question for adding Google fonts. It used to be a link in ‘header’ and now its code? How come?

    Thanks.

    Dev

    #95130

    Sridhar Katakam
    Participant
    Post count: 985

    I think enqueueing is the way to go whether it is custom css or Google fonts.


    #95140

    dev
    Participant
    Post count: 453

    Thanks, but can you give me some technical reason for why you think enqueueing is more efficient than the “link” method?

    Dev

    #95144

    Sridhar Katakam
    Participant
    Post count: 985

    You may find the answer in http://code.tutsplus.com/articles/how-to-include-javascript-and-css-in-your-wordpress-themes-and-plugins–wp-24321. Scroll down to “So, Why Doesn’t Everyone Already Do Things This Way?” section.


    #95196

    dev
    Participant
    Post count: 453

    Thanks. The code method works fine for both .css and fonts. I’ll do it this way from now on.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.