Making a Theme With Bones: Finishing Off

Making a Theme With Bones: Finishing Off

Tutorial Details
  • Program: WordPress
  • Version: 3.0+
  • Difficulty: Medium
  • Estimated Completion Time: 35 minutes

Final Product What You'll Be Creating

This entry is part 2 of 3 in the series Making a Theme With Bones

We are using a starter theme to build a new site.

We’re going to follow straight on from the previous tutorial in this series. So let’s jump into it:


Step 13: Setting Heading and Body Copy Fonts

We will use two fonts from the Google Font library: Arvo and PT Sans. Put this code in the functions.php file. This code will pull in the CSS code which contains the font-face properties.

function wptuts_googlefonts_styles() {
	// Enqueue the font stylesheets like this:
	wp_enqueue_style( 'googlefonts-arvo', 'http://fonts.googleapis.com/css?family=Arvo' );
	wp_enqueue_style( 'googlefonts-pt-sans', 'http://fonts.googleapis.com/css?family=PT+Sans' );
}  
add_action( 'wp_enqueue_scripts', 'wptuts_googlefonts_styles' );

Let’s set Arvo for headings (base.less) and PT Sans for body copy. We can set the font with font-family. We also define serif and sans-serif which means we will get a default font if the custom font can’t be loaded.

h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5 {
	font-family: 'Arvo', serif;
	...
}

...

body {
	font-family: 'PT Sans', sans-serif;
	...
}

Step 14: H1, footer, header

The font size will be 4em. We have to modify the footer.php to add content and the base.less file for styles. Set the background (with background), bottom border (with border-bottom) and padding (top 10px, 0px for left and right, and 15px for bottom). For the header a noise gradient resized by 10 times will be good, saved as a file (kotkoda_header_bg.gif) and it has to be in the bones/library/images folder. The CSS code goes into the base.less file. The graphics will be repeated horizontally (repeat-x) and start in the top left (0 0).

h1, .h1 {
	font-size: 4em; /*2.5em*/
	line-height: 1.333em;
}
<p class="attribution">&copy; <?php echo date('Y'); ?> <?php bloginfo('name'); ?>.
This page is protected by the <em>XXYY government and army</em>.
Read everything carefully.
You can reach us by mail at <strong>kukori @ kotkoda.com</strong>.
</p>
.footer {
	clear: both;
	background: #f6f6f6;
	border-bottom: 5px solid #FFD400;
	padding: 10px 0 15px;
}
.header {
	background: url(../images/kotkoda_header_bg.gif) 0 0 repeat-x;
}

This is how it looks after modifying the footer.

After footer modifications

This is how it looks after adding the graphics.

After footer modifications

Step 15: Favicon and Page Title

We can set a new 16×16 favicon in the header.php file. In the href part we set the path of the icon, get_template_directory_uri will give us the template’s main directory URL. For the page title, replace the original code with this one and set the description in the admin interface. This PHP code will echo the blog’s description field.

<link rel="shortcut icon" href="<?php echo get_template_directory_uri(); ?>/library/images/kotkoda_favicon.ico">
...
<title><?php echo get_bloginfo( 'description', 'display' ); ?></title>

It will look like this after adding the icon.

After adding the favicon

Step 16: Page Menu

The main navigation for pages will get a minimal style as well. With display set to inline the look will be horizontal and the left border will be white (border-left).

.menu {
	border-left: 1px solid @white;
	padding-left: 1em;
}

.menu ul {
	padding: 1em 0 1em;
	height: 1.5em;
}

.menu ul li {
	display: inline;
	margin-right: 1em;
}

The new look of the main menu.

After setting main menu

Step 17: Comment Styles

Comments will get a simpler look. The styles named odd and even should be empty (or commented out) and the li element gets a border-left. The right date text link will be white as well, let’s color it to @white. The reply button will get a new style too. We have to set the color, the background color and the opacities (these are deleted).

.commentlist {

	li {
		position: relative;
		clear: both;
		overflow: hidden;
		list-style-type: none;
		margin-bottom: 1.5em;
		padding: 0.7335em 10px;
		border-left: 1px solid @white;
		
		...
		
		/* general comment classes */
		.alt {}
		.odd {
			/*background: #eee;*/
		}
		.even {
			/*background: #fefefe;*/
		}

...
	/* vcard */
	.vcard {
		margin-left: 50px;

		cite.fn {
			font-weight: 700;
			font-style: normal;

			a.url {}

		}

		time {
			float: right;

			a {
				color: @white;
			...

...
	/* comment reply link */
	.comment-reply-link {
		text-decoration: none;
		float: right;
		background: @white;
		padding: 3px 5px;
		color: #999;
		margin-bottom: 10px;
		font-weight: 700;
		font-size: 0.9em;

		&:hover,
		&:focus {
			color: @kotkoda-grey;
		}

The new look.

After comment modification

Step 18: Comment Box and Button

We don’t need the border (border: 0) and the background should be @white (base.less). There are a lot of fancy styles we don’t need (transition, rounded, gradient) so we have to change borders and backgrounds, and delete roundness and transition. This goes into our mixins.less file.

textarea {
	padding: 3px 6px;
	background: @white; /*#efefef;*/
	border: 0; /*2px solid #cecece;*/
}
.button, .button:visited {
	/*border: 1px solid darken(@kotkoda-grey, 13%);
	border-top-color: darken(@kotkoda-grey, 7%);
	border-left-color: darken(@kotkoda-grey, 7%);*/
	border: 0;
	padding: 4px 12px;
	color: #999;
	display: inline-block;
	font-size: 13px;
	font-weight: bold;
	text-decoration: none;
	/*text-shadow: 0 1px rgba(0,0,0, .75);*/
	cursor: pointer;
	margin-bottom: 20px;
	line-height: 21px;
	/*.transition();*/
	/*.rounded(4px);*/
	/*.css-gradient(#999,darken(#999, 5%));*/

	&:hover, &:focus {
		color: @kotkoda-grey;
	  	/*border: 1px solid darken(@kotkoda-grey, 13%);
	  	border-top-color: darken(@kotkoda-grey, 20%);
	 	border-left-color: darken(@kotkoda-grey, 20%);*/
		border: 0;
		/*.css-gradient(darken(#444, 5%),darken(#444, 10%));*/
	}
	
	&:active {
		/*.css-gradient(darken(@kotkoda-grey, 5%),@kotkoda-grey);*/
		color: @kotkoda-grey;
	}	
}

The look after styling.

After comment box and button modification

Step 19: Info Box

Let’s change the info box background to light yellow, which is @alert-yellow (in mixins.less). We don’t need a border, so set it to zero.

.info { 
	/*border-color: darken(@alert-blue, 5%); */
	border: 0;
	background: @alert-yellow;
}

Step 20: Theme Admin Screenshot

The last step is to delete the default screenshot and replace with the Kotkoda one we made.

Final theme screenshot for admin

Finished

Here is how the theme looks finished in 600 pixels wide. In the next tutorials we will clean the theme from unnecessary parts then prepare it for submission to ThemeForest.

After comment box and button modification

Other parts in this series:Making a Theme With Bones: Getting StartedMaking a Theme With Bones: Cleaning Up
Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • Frank Pereiro

    This really is a great tutorial, I’d wish there were many more like this one.

    Thank you very much, always a pleasure to read your tips from my reader.

  • Pingback: Qoozon | Daily digest. September 4

  • Chris

    This series looked like it had potential but this article really seemed to drop the ball. I appreciate the fact that the Bones theme was looked at in a broad context but it would have been nice if you showed how to integrate things like jquery from a CDN. I think a more detailed build would have been extremely useful for those who are interested in starting with this theme. I’ve been building away with the Bones theme for a couple of weeks now and there is quite a few things that need to be done before this theme is really usable in the real world.

    • http://wp.envato.com/ Japh Thomson
      Staff

      Hi Chris,

      Thanks so much for your feedback! We would love to hear what you would do next in this scenario.

      Also, it’s not very good practice to integrate jQuery from a CDN in a publicly released theme. Using WordPress’ included jQuery is the best approach.

      • Chris

        Hey Japh,
        I suppose that it might cause some trouble for people who aren’t insuring that everything is setup properly with queuing jquery but could it not be helpful to pull jquery from google so that if the user has it cached then it is not downloaded again? You would have to make sure there is a backup in case but many starter themes, such as Roots, pull in jquery from google.
        Once again, thanks for this introduction to the bones theme. I’m sure that many will find it useful!

        • http://wp.envato.com/ Japh Thomson
          Staff

          Hey Chris, have a read of the article I linked for Zeroun below. I explain some of this in that article.

          Thanks for mentioning Roots, I’ll take a look at how they do it and ask them why.

          • Chris

            Hey Japh,
            Not sure if you got a chance to look at the Roots theme yet but I did read that article you linked up to and I appreciate that. I think part of the reason there is some confusion is because I’m talking about building a wordpress theme for personal use or something you’ll hand off to the client. I think that a CDN could work great if you know what is going to be included in the theme but agree that if you are releasing the theme publicly to designers (who may not know what conflicts could occur if they are not careful) that perhaps you should just stick with the jquery included in wordpress.
            As always, I really appreciate the continued conversations that happen at the end of articles. Sometimes there is more meat here than in the article! That is a good thing in my opinion.

    • Tom

      I have to agree with Chris. I was stoked to be notified of the WP Bones series originally. While “part I” did not shed light on anything new to me, it was well done and excited me about what was to come. This “part II” article seemed as if someone was under a deadline, was behind and just needed to get something out the door.

      While I can appreciate deadlines, this one just doesn’t seem up to par with part I nor the Tutsplus network standard I’ve come to enjoy. I would love to see WP Bones revisited with some more “meat” on the bones in a continuation of this series. We know you can do it!

      Thanks and blessings.

      P.S. Yup, pun intended. :)

  • zetoun

    Hello,
    just a word about your wptuts_googlefonts_styles() function

    because you are making a theme and not a plugin, you should put your google fonts’s css directly in the header.php and use wp_enqueue_style() only when making a plugin

    Regards.

    • http://skematiktheme.com Matthew Jones

      Actually, I really like it when all css in enqueued provided they are also registered. That way, if I am making a child theme from this theme, I don’t have to rewrite the header, I can just deregister the style.

      • Tim

        Exactly my thoughts.

    • http://www.elimcmakin.com Eli McMakin

      zeroun, why? why not use abstraction to clean the header?

      • http://www.java4s.com jaswanth

        Yeah i too agree with Eli McMahin, Please respond.

    • http://wp.envato.com/ Japh Thomson
      Staff

      Hi Zetoun, thanks for the feedback, but that is not actually the case. It’s best practice to do this in both themes and plugins. Have a read of our article on How to Include JavaScript and CSS in Your WordPress Themes and Plugins.

  • Steven

    Bones comes with a favicon in the root theme file folder and a link to it in the header. All you have to do is overwrite the favicon with your own favicon.ico. No need to spend time writing a new favicon directory path.

    Wondering why this made it in the article?

  • Gremlin

    We need more!!! Maybe some series on how to build REAL (jqurey, slider etc.) theme with bones…
    Regards

  • Erwin Schober

    Just a short question: Is it recommended embedding Google webfonts via enqueue style? I read some time ago that the performance-optimized way to embed fonts would be to directly write the code into the header.php file. see: http://www.wpbeginner.com/wp-themes/how-add-google-web-fonts-wordpress-themes/ what you think? thanks in advance..

    • http://wp.envato.com/ Japh Thomson
      Staff

      Hi Erwin, as you can read in the comments of that post, Konstantin points out that you should use wp_enqueue_style. This will mean they are output into the header.php rather than @import anyway.

      Note that the performance benefit mentioned in the post is referring to using <link /> vs @import, because using @import will wait to download the first stylesheet before loading the fonts, rather than loading them in parallel.

  • http://driscollalford.weebly.com/ Hedley Gentry

    CMS is better to other Management System because CMS was designed to simplify the complex task of writing numerous
    versions of code and to make the website development process more
    flexible.

  • http://www.facebook.com/profile.php?id=527652482 Hjoaco Mg

    Sorry if I make them waste their time, but as active LESS in Bones, Bones doc does not have to start, that’s wrong, I have two hours guessing, do not say anything online that is not compiled with LESS, what interests me is that the make a change this change becomes oh at least someone who knows how to do as I say, all things posted only compile with lESS, not a problem compiling there are thousands of post that say how to compile with lESS.

    Not if someone understands.

  • Mike

    hi, I’m almost done but very stucked at step 14 (where do i put the lines .footer and .header).. And second step 19 can’t find the .info to tweak).. For the rest: Great tutorial, thanx!!

  • caravaggisto

    This is informative, but it’s still unclear to me how the changes in less code get processed. I downloaded the theme, activated it, edited less files under ../themes/bones-master/library/less/, and expected to see changes – naively. I thought there might be some sort of server-side processing. How is this supposed to work? Especially for development, I don’t want to be compiling and redeploying css all the time.

    Edit: I’m not an experienced WP theme developer.

    • Healite

      I made sure I had live-reload (you could use any compatible less compiler) up and running in the background with the Bones folder in my local development folder loaded in it and it worked! I had some trouble at this stage too as it wasn’t mentioned in the tutorial.

      I’d really like to see a more in-depth tutorial on using base theme’s like Bones.

      Thanks for your time everyone one at the tuts+ network.