如果家庭css为wordpress

css conditioning if user is in homepage of wordpress?

I put this

<?php if(is_home()) {
echo '<link rel="stylesheet" href="customHome.css">'
} ?>

into my page editor and it did applied the css. but because it's using echo so there will be some bug. it echo out some thing like

> echo ' ‘ } ?>

in the end of the post.

I want to know where else should I include that? I tried to put in header but it doesn't work.

You can append css by using wp_enqueue_scripts like;

function custom_css() {
    if (is_home()) {
        wp_enqueue_style( 'custom_style_name', 'path_to_your_css' );
    }
}

add_action( 'wp_enqueue_scripts', 'custom_css' );

Put above code block to functions.php