{"id":16225,"date":"2016-06-23T05:50:34","date_gmt":"2016-06-23T05:50:34","guid":{"rendered":"http:\/\/www.oracletutoring.ca\/blog\/?p=16225"},"modified":"2016-06-23T05:51:36","modified_gmt":"2016-06-23T05:51:36","slug":"wordpress-blogging-adding-a-style-sheet-to-wordpress","status":"publish","type":"post","link":"https:\/\/www.oracletutoring.ca\/blog\/wordpress-blogging-adding-a-style-sheet-to-wordpress\/","title":{"rendered":"WordPress blogging:  Adding a style sheet to WordPress"},"content":{"rendered":"<h1>The tutor shows a way to add a style sheet to a WordPress site.<\/h1>\n<p>There are several ways to add a style sheet to WordPress. Herein, I&#8217;ll show how I&#8217;ve done so.<\/p>\n<p>Let&#8217;s imagine the div below is meant to be styled from an external style sheet:<\/p>\n<div class=\"hair\">This div should have pink hair!<\/div>\n<p>&NewLine;<\/p>\n<p>Assuming the div above is <span style=\"font-family:monospace\">class=&#8221;hair&#8221;<\/span>, the following style sheet could be added as <span style=\"font-family:monospace\">\/blog\/styles\/hairstyle.css<\/span><\/p>\n<div style=\"font-family:monospace;font-size:105%\">\n<p>.hair{<br \/>\ndisplay:block;<br \/>\nmargin:auto;<br \/>\nfont-size:200%;<br \/>\ncolor:white;<br \/>\nbackground-color:pink;<br \/>\ntext-align:center;<br \/>\nwidth:50%;<br \/>\n}\n<\/p><\/div>\n<p>Next, the following code, added inside the WordPress Theme Functions file, includes the style sheet as the page is rendered:<\/p>\n<div style=\"font-family:monospace;font-size:105%\">\n<p>function hairstyle(){<br \/>\nwp_register_style(&lsquo;hairstyle&rsquo;,&#8217;\/styles\/hairstyle.css&#8217;);<br \/>\nwp_enqueue_style(&#8216;hairstyle&#8217;);<br \/>\n}<br \/>\nadd_action(&#8216;wp_enqueue_scripts&#8217;,&#8217;hairstyle&rsquo;);<\/p>\n<\/div>\n<p>This method takes concentration to apply.  I normally use inline styles, but sometimes an external style sheet makes more sense.<\/p>\n<p>I&#8217;ll be talking more about WordPress in future posts:)<\/p>\n<p>Source:<\/p>\n<p><a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/wp_register_style\/\">developer.wordpress.org<\/a><\/p>\n<p>Jack of <a href=\"https:\/\/www.oracletutoring.ca\">Oracle Tutoring by Jack and Diane,<\/a> Campbell River, BC.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;ll show how I&#8217;ve done so. Let&#8217;s imagine the div below is meant to &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.oracletutoring.ca\/blog\/wordpress-blogging-adding-a-style-sheet-to-wordpress\/\"> <span class=\"screen-reader-text\">WordPress blogging:  Adding a style sheet to WordPress<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1548],"tags":[1670,1669,1666,1667,1668],"class_list":["post-16225","post","type-post","status-publish","format-standard","hentry","category-wordpress","tag-adding-a-style-sheet-to-wordpress","tag-theme-functions","tag-wordpress-editor","tag-wp_enqueue_style","tag-wp_register_style"],"_links":{"self":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/16225","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/comments?post=16225"}],"version-history":[{"count":32,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/16225\/revisions"}],"predecessor-version":[{"id":16257,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/16225\/revisions\/16257"}],"wp:attachment":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/media?parent=16225"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/categories?post=16225"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/tags?post=16225"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}