{"id":1441,"date":"2017-03-13T02:40:53","date_gmt":"2017-03-13T02:40:53","guid":{"rendered":"http:\/\/websterart.com\/wordpress\/?p=1441"},"modified":"2017-03-13T06:34:00","modified_gmt":"2017-03-13T06:34:00","slug":"adding-logo-wordpress-custom-theme","status":"publish","type":"post","link":"https:\/\/websterart.com\/wordpress\/2017\/03\/adding-logo-wordpress-custom-theme\/","title":{"rendered":"Adding a logo in a WordPress custom theme"},"content":{"rendered":"<h2><span style=\"color: #008080;\">Add a logo image function to your custom theme<\/span><\/h2>\n<p>Geek alert! This post is for the students in my WordPress class. There is nothing here worth reading if you are looking for stories about climbing or painting. <!--more--><\/p>\n<p>I needed to create one more lesson to finish out the quarter. My choices for creating the content of the lesson\u00a0 were: inDesign, Canvas, HTML, Word or a youtube video via Camtashia. I settled on WordPress because it seemed the easiest and most durable\u00a0 platform. Plus I&#8217;ve learned a lot online from other authors, and this is a way for me to give back.<\/p>\n<h2><span style=\"color: #008080;\">Lesson 4, Final<\/span><\/h2>\n<p>We stopped here last week on our custom theme. We\u2019ve got a right hand sidebar, but no images in header:<\/p>\n<p><a href=\"http:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-6.32.32-PM.png\"><img decoding=\"async\" class=\"aligncenter wp-image-1447 size-full\" src=\"http:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-6.32.32-PM.png\" alt=\"\" width=\"925\" height=\"975\" srcset=\"https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-6.32.32-PM.png 925w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-6.32.32-PM-150x158.png 150w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-6.32.32-PM-285x300.png 285w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-6.32.32-PM-768x810.png 768w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-6.32.32-PM-171x180.png 171w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-6.32.32-PM-569x600.png 569w\" sizes=\"(max-width: 925px) 100vw, 925px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<div><\/div>\n<div><\/div>\n<div><\/div>\n<div><\/div>\n<div><\/div>\n<div><strong>\u00a0<\/strong><\/div>\n<div><strong>Getting the logo to appear in top left corner of &lt;header&gt;:<\/strong><\/div>\n<div><\/div>\n<div><span style=\"color: #ff2600;\"><b>(1.)<\/b><\/span> To get the logo to appear, first add an <strong>images<\/strong> folder into your custom theme folder, and copy across any images you would like to have in your theme. Note, these are images that will be pre-installed into the theme, rather than images that get uploaded to WordPress via the \u201cadd media\u201d command.<\/div>\n<div><a href=\"http:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-6.45.30-PM.png\"><img decoding=\"async\" class=\"aligncenter wp-image-1448 size-full\" src=\"http:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-6.45.30-PM.png\" alt=\"\" width=\"994\" height=\"724\" srcset=\"https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-6.45.30-PM.png 994w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-6.45.30-PM-150x109.png 150w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-6.45.30-PM-412x300.png 412w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-6.45.30-PM-768x559.png 768w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-6.45.30-PM-180x131.png 180w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-6.45.30-PM-300x219.png 300w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-6.45.30-PM-600x437.png 600w\" sizes=\"(max-width: 994px) 100vw, 994px\" \/><\/a><\/div>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #ff0000;\"><span style=\"color: #000000;\">******** <\/span><\/span><\/p>\n<p><strong><span style=\"color: #ff0000;\">(2.) <\/span><\/strong>Add this code into your <strong>functions.php<\/strong> file. Place it after the last function which was: <span style=\"color: #993300;\">register_sidebar(array(&#8230;))<\/span> but before the closing <span style=\"color: #993300;\">?&gt;<\/span>\u00a0 php tag. Note, you can read much more about this custom-header function here: <a href=\"https:\/\/codex.wordpress.org\/Custom_Headers\" target=\"_blank\">https:\/\/codex.wordpress.org\/Custom_Headers<\/a><\/p>\n<p>Here is the code:<\/p>\n<pre class=\"lang:default decode:true\">$args = array(\r\n     'width'         =&gt; 231,\r\n     'height'        =&gt; 231,\r\n     'default-image' =&gt; get_template_directory_uri() . '\/images\/lightbulb.png',\r\n     'uploads'       =&gt; true,\r\n);\r\nadd_theme_support( 'custom-header', $args );\r\n\r\n<\/pre>\n<p>Here is the new code in context:<\/p>\n<p><a href=\"http:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-6.57.48-PM.png\"><img decoding=\"async\" class=\"aligncenter wp-image-1450 size-full\" src=\"http:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-6.57.48-PM.png\" alt=\"\" width=\"965\" height=\"800\" srcset=\"https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-6.57.48-PM.png 965w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-6.57.48-PM-150x124.png 150w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-6.57.48-PM-362x300.png 362w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-6.57.48-PM-768x637.png 768w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-6.57.48-PM-180x149.png 180w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-6.57.48-PM-300x249.png 300w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-6.57.48-PM-600x497.png 600w\" sizes=\"(max-width: 965px) 100vw, 965px\" \/><\/a><\/p>\n<div><\/div>\n<div>\u00a0<span style=\"color: #ff0000;\"><span style=\"color: #000000;\">********<\/span><\/span><\/div>\n<div><\/div>\n<div><strong><span style=\"color: #ff0000;\">(3.)\u00a0<\/span><\/strong>Go to <strong>header.php<\/strong> and modify the starting &lt;header&gt; tag by adding this inline style sheet rule as shown below.<\/div>\n<div>Note that our <strong>style.css<\/strong> file already has a rule telling an image to appear in the background of the &lt;header&gt;. We can ignore that because this new inline rule will override that one in the external style sheet.<\/div>\n<div>\n<pre class=\"lang:default decode:true \">&lt;body id=\"home\"&gt;\r\n&lt;div id=\"wrapper\"&gt;\r\n     &lt;header class=\"masthead\" style=\"background: url(&lt;?php header_image(); ?&gt;) top left no-repeat;\"&gt;\r\n          &lt;h1&gt;&lt;?php bloginfo('name'); ?&gt;&lt;\/h1&gt;\r\n     &lt;\/header&gt;\r\n\r\n<\/pre>\n<p>You should see the image appear as shown below.<\/p>\n<p><a href=\"http:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-7.12.07-PM.png\"><img decoding=\"async\" class=\"aligncenter wp-image-1454 size-full\" src=\"http:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-7.12.07-PM.png\" alt=\"\" width=\"1924\" height=\"1168\" srcset=\"https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-7.12.07-PM.png 1924w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-7.12.07-PM-150x91.png 150w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-7.12.07-PM-494x300.png 494w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-7.12.07-PM-768x466.png 768w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-7.12.07-PM-1687x1024.png 1687w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-7.12.07-PM-180x109.png 180w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-7.12.07-PM-300x182.png 300w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-7.12.07-PM-600x364.png 600w\" sizes=\"(max-width: 1924px) 100vw, 1924px\" \/><\/a><\/p>\n<\/div>\n<p>NOTE: Behind the scenes, WordPress creates an association between custom-header, and header_image(). I have no idea how or where that happens, but you could google it for an answer.<\/p>\n<p><strong>If it doesn&#8217;t work&#8230;<\/strong><\/p>\n<p>********<\/p>\n<p><strong><span style=\"color: #ff0000;\">(3-a.)\u00a0<\/span><\/strong>View the source code of the webpage. Scroll down to the <span style=\"color: #993300;\">&lt;header&gt;<\/span> tag and examine the <span style=\"color: #993300;\">style=&#8221;background: url();&#8221;<\/span> property. Note how it is no longer a <span style=\"color: #993300;\">&lt;?php \u00a0 \u00a0?&gt;<\/span> value. Now the url() declaration is \u00a0an absolute address that leads from the root of the website down to the lightbulb.png \u00a0So, if your logo image isn&#8217;t showing up, examine the images folder. Is it in there? Does it have a different name? If the site has crashed, or the url(); doesn&#8217;t look like the code below, try to find some logic in the error messages. PHP usually gives file names and code line numbers when it crashes. Examine those and compare your code to my code here, or in the finished theme I gave you in the resources folder.<\/p>\n<pre class=\"lang:default decode:true \">&lt;body id=\"home\"&gt;\r\n&lt;div id=\"wrapper\"&gt;\r\n\t&lt;header class=\"masthead\" style=\"background: url(http:\/\/localhost\/wordpress-delete\/wp-content\/themes\/deletemark\/images\/lightbulb.png) top left no-repeat;\"&gt;\r\n\t\t&lt;h1&gt;Mary Jones&lt;\/h1&gt;\r\n\t&lt;\/header&gt;\r\n\t&lt;nav class=\"main-menu\"&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p>You may notice that the tiling background image has also suddenly appeared. That is because we have an existing style sheet rule in our <strong>style.css<\/strong> that tells <strong>headerPinstripe.png<\/strong> to appear from the images folder.<\/p>\n<pre class=\"lang:default decode:true \">#wrapper {\r\n\tmargin-right: auto;\r\n\tmargin-left: auto;\r\n\tpadding: 0;\r\n\twidth: 80%;\r\n    background: #fff url(images\/headerPinstripe.png) top left repeat-x;\r\n\tmax-width: 1400px;\r\n\tbackground-color: #fff;\r\n\t\r\n\tborder-bottom-right-radius: 18px;\r\n\tborder-bottom-left-radius: 17px;\r\n\t-webkit-box-shadow: 7px 7px 5px 0px rgba(50, 50, 50, 0.75);\r\n\t-moz-box-shadow:    7px 7px 5px 0px rgba(50, 50, 50, 0.75);\r\n\tbox-shadow:         7px 7px 5px 0px rgba(50, 50, 50, 0.75);\r\n}\r\n\r\n<\/pre>\n<p>Even though we are developing this at http:\/\/localhost\/customtheme, we don&#8217;t have to go through the entire\u00a0 Duplicator zipping, upload and install process to get these changes online into your live WordPress installation.<\/p>\n<div><span style=\"color: #ff0000;\"><span style=\"color: #000000;\">********<\/span><\/span><\/div>\n<div><strong><span style=\"color: #ff0000;\">(4.) <\/span><\/strong>Go online and log in to cpanel. Double click your way down through these folders: <span style=\"color: #993300;\">public_html &gt; final &gt; wp-content &gt; themes &gt; yourtheme<\/span>.<\/div>\n<div><\/div>\n<div>\n<div><span style=\"color: #ff0000;\"><span style=\"color: #000000;\">********<\/span><\/span><\/div>\n<div><strong><span style=\"color: #ff0000;\">(5.) <\/span><\/strong>Use the cpanel button for <strong>create new folder<\/strong> and name it <strong>images<\/strong>. Double click inside the images folder and click the cpanel <strong>upload<\/strong> button. Drag in any images you want to be in the theme. Examples would be lightbulb.png, headerPinstripe.png, left-tile.jpg, right-tile.jpg. Other images, such as photos are better uploaded from the dashboard via the upload media button.<\/div>\n<\/div>\n<div>\n<div><\/div>\n<div><span style=\"color: #ff0000;\"><span style=\"color: #000000;\">********<\/span><\/span><\/div>\n<div><strong><span style=\"color: #ff0000;\">(6.) <\/span><\/strong>Navigate back to the <span style=\"color: #993300;\">themes &gt; yourtheme<\/span> folder. Upload: <strong>functions.php, header.php<\/strong> and any other files you might have changed in this go round.<\/div>\n<\/div>\n<div>\u00a0This is one of the benefits of developing a custom theme. We develop locally in xampp where no one can see us make mistakes, then we just send up the changed files.<\/div>\n<div><\/div>\n<div>Once you&#8217;ve got it uploaded to the remote server and working, you may want to change out the image. At this point, it is best to do it through the dashboard. We set it up as part of the theme so that users of the theme could easily change our default\u00a0for their own image. We could obviously change the image using the PHP shown above. But the whole point of setting this up as a header image function was that so users of our theme could change the logo image easily by just pressing WordPress buttons in the dashboard.\u00a0Wordpress&#8217;s goal \u00a0is to make creating web content as easy as editing a Word Document.<\/div>\n<div><span style=\"color: #ff0000;\"><span style=\"color: #000000;\">********<\/span><\/span><\/div>\n<div><strong><span style=\"color: #ff0000;\">(7.) <\/span><\/strong>To change out the logo image, log into the dashboard on the \u00a0remote site (\/wp-admin) and go to the \u00a0<span style=\"color: #993300;\">appearance &gt; customize &gt; Header Image<\/span>. Note: that new button for <strong>Header Image<\/strong> is there because of the PHP we just edited. It wasn&#8217;t there before.<\/div>\n<div><a href=\"http:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-11.14.12-PM.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-1464\" src=\"http:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-11.14.12-PM.png\" alt=\"\" width=\"1970\" height=\"1268\" srcset=\"https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-11.14.12-PM.png 1970w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-11.14.12-PM-150x97.png 150w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-11.14.12-PM-466x300.png 466w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-11.14.12-PM-768x494.png 768w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-11.14.12-PM-1591x1024.png 1591w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-11.14.12-PM-180x116.png 180w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-11.14.12-PM-300x193.png 300w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-11.14.12-PM-600x386.png 600w\" sizes=\"(max-width: 1970px) 100vw, 1970px\" \/><\/a><\/div>\n<div>\u00a0.<\/div>\n<div><\/div>\n<div>And here you have nice little buttons for swapping in a new logo (header) image:<a href=\"http:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-11.17.21-PM.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-1465\" src=\"http:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-11.17.21-PM.png\" alt=\"\" width=\"2116\" height=\"1618\" srcset=\"https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-11.17.21-PM.png 2116w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-11.17.21-PM-150x115.png 150w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-11.17.21-PM-392x300.png 392w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-11.17.21-PM-768x587.png 768w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-11.17.21-PM-1339x1024.png 1339w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-11.17.21-PM-180x138.png 180w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-11.17.21-PM-300x229.png 300w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/03\/Screen-Shot-2017-03-12-at-11.17.21-PM-600x459.png 600w\" sizes=\"(max-width: 2116px) 100vw, 2116px\" \/><\/a><\/div>\n<div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Add a logo image function to your custom theme Geek alert! This post is for the students in my WordPress class. There is nothing here worth reading if you are looking for stories about climbing or painting.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,130,131],"tags":[134,133,132],"class_list":["post-1441","post","type-post","status-publish","format-standard","hentry","category-blog","category-teaching","category-wordpress","tag-add-custom-theme-logo-image","tag-add-theme-logo","tag-wordpress-tutorial"],"_links":{"self":[{"href":"https:\/\/websterart.com\/wordpress\/wp-json\/wp\/v2\/posts\/1441","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/websterart.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/websterart.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/websterart.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/websterart.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1441"}],"version-history":[{"count":20,"href":"https:\/\/websterart.com\/wordpress\/wp-json\/wp\/v2\/posts\/1441\/revisions"}],"predecessor-version":[{"id":1467,"href":"https:\/\/websterart.com\/wordpress\/wp-json\/wp\/v2\/posts\/1441\/revisions\/1467"}],"wp:attachment":[{"href":"https:\/\/websterart.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1441"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/websterart.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1441"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/websterart.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1441"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}