How to link external css in wordpress? [closed]

…衆ロ難τιáo~ 提交于 2019-12-04 21:56:58

Your best option would be to enqueue the file onto the page you want.

In the functions.php file, add this code

// Register style sheet.
add_action( 'wp_enqueue_scripts', 'register_custom_plugin_styles' );

/**
 * Register style sheet.
 */
function register_custom_plugin_styles() {
    wp_register_style( 'my-stylesheet', 'STYLESHEETS URL' );
    wp_enqueue_style( 'my-stylesheet' );
}

If you only want this on specific pages, then you'll need to put it round an if statement checking what page you are currently on to know if to run the above script.

Read more about enqueuing scripts here: http://codex.wordpress.org/Function_Reference/wp_register_style

You can use enqueue or you can go to your theme's style.css file and then inside you would use the @import at-rule to link to.

Example:

@import url("//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css");

Alternatively you could edit the header.php file in the theme to link to an external stylesheet.

Example:

<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!