WordPress Theme Development From Scratch - 3. Enqueuing CSS and JS to W...
full screen view: https://youtu.be/KtMwTBl-j8I
functions.php file:
<?php // Create the function function load_css () { // Register the style wp_register_style( 'my-style', get_template_directory_uri() . '/style.css', array(), false, 'all' ); // Name, get template URL + CSS filename, dependencies, version number, media // Enqueue the style wp_enqueue_style('my-style'); } // Execute the function add_action('wp_enqueue_scripts', 'load_css');Yellow hight portion can be customized.
- 'my-style' string name, could be any.
- '/style.css' string location, could be /css/style.css. depend on your style.css file location.
*link functions file with pages, still need some work:
1. add <?PHP wp_head(); ?> right beyond the end of </head> in the single.php file(similar as HTML file)
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?> id="top">
<?php get_header(); ?>
2.add <?PHP wp_footer(); ?> right beyond the end of </body>
<?php wp_footer(); ?>
</body>
</html>
and then your style.css will work properly. (it only affect your single page not affect your Sedona site)
Comments
Post a Comment