WordPress blogging: Adding a style sheet to WordPress

The tutor shows a way to add a style sheet to a WordPress site.

There are several ways to add a style sheet to WordPress. Herein, I’ll show how I’ve done so.

Let’s imagine the div below is meant to be styled from an external style sheet:

This div should have pink hair!

Assuming the div above is class=”hair”, the following style sheet could be added as /blog/styles/hairstyle.css

.hair{
display:block;
margin:auto;
font-size:200%;
color:white;
background-color:pink;
text-align:center;
width:50%;
}

Next, the following code, added inside the WordPress Theme Functions file, includes the style sheet as the page is rendered:

function hairstyle(){
wp_register_style(‘hairstyle’,’/styles/hairstyle.css’);
wp_enqueue_style(‘hairstyle’);
}
add_action(‘wp_enqueue_scripts’,’hairstyle’);

This method takes concentration to apply. I normally use inline styles, but sometimes an external style sheet makes more sense.

I’ll be talking more about WordPress in future posts:)

Source:

developer.wordpress.org

Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.

WordPress: where is functions.php?

The tutor shares a bit he was curious about: the location of functions.php in the WordPress directory structure.

Doing a little customizing with my WordPress site (this one), I came upon the question of where the functions.php file is located. After some navigation, I observe that, for mine, functions.php has the path

site_domain_name/blog/wp-includes/functions.php

HTH:)

Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.