VoodooPress 1 Year Anniversary T-shirt Giveaway!

This contest is open until the end of the day on February 16, 2012. You can enter using each method once per day!

VoodooPress is exactly 1 year old today! One ear ago we started content development with our Welcome post, and on February 16th we officially launched with this post. Since then, VoodooPress has grown up quite a bit. We’ve been through 2 themes now (2010, 2011) and we are looking forward to another facelift with the launch of WordPress 3.4 and the Twenty Twelve theme. We’ve found a decent group of friends here, who have contributed a lot to discussions and some cool code too. The first year has been a lot of fun, and I’m looking forward to many more years of poking WordPress with a stick and writing about what happens. As a thanks to the readers, let’s have a bit of fun here and give away some shirts!

I’m going to admit here, I’m going out on a limb a bit. First, I’m assuming anybody actually cares enough about VoodooPress to want a shirt! But who wouldn’t really? I mean, Mr. Voodoo guy is pretty cool looking.

The second risk is that I haven’t actually seen the shirts, physically, yet. I have a VoodooPress shirt using this exact logo, but it was just a transfer. I’m having the giveaway shirts silk screened in 5 colours. That is supposed to mean they will look super fabulous, but… never know until I get them!

I think that covers everything… why we are giving away shirts, and what the shirts look like. Am I missing anything? Oh right… you want to know HOW to enter don’t you? It’s simple really. I’ve got a few ways for you to enter.

Over on my sidebar —–> Just over there… see those social icons? Click ’em! And follow / like / circle me! That is an entry right there for each of those sites. Already have VoodooPress added? No worries, existing peeps are automatically entered. I won’t forget about my OG peeps.

So that’s a one time entry. Next up, daily fun! I’m gonna embed a post from each of those sites. If you would please share/retweet these posts. Once a day for an entry each day.

Here’s a link to a post on each of those sites, please share these each day for an entry.

FaceBook.

Please share this post daily on FaceBook for an entry.

Twitter.

A daily retweet of this post would be super swell as well!

Google+

Please share this daily on Google+, it’d be super cool if you did it as a public post!

I believe the buttons under this post do the same thing. You can +1 publicly, you can tweet this post, or like it (which that is different from sharing). Do it either way, I’ll only track one entry per day, per person, per service… make sense?

That’s it. We’ll have the drawing on (or near, just in case something happens) February 16th. I’ve told you how to enter! Basically, the more you get the word out about VoodooPress, the more chances you have to win!

Thanks for a great first year everybody! I hope you guys have fun with this little giveaway, and I look forward to creating the next year’s worth of awesome content!

Here’s the nitty-gritty. I’m not sure how many shirts I’m giving away. Depends on how much participation I get. It’ll be at least 6 shirts though.

I’ll track all entries each day on a spreadsheet. The winners will be randomly selected, and I will contact you through the service you entered on. If I don’t hear from you in 2 days, I’ll draw again.

You have to be comfortable giving me your mailing address so I can ship you the shirt. I promise not to even save those details. I will ship, and destroy the info.

I can’t guarantee shirts sizes. I had to pre-order these things, so I only have so many of each size.

There may be some hiccups along the way here. I’ve never done anything like this before… Dunno exactly what I’m doing here!

Use More Screen Real Estate by Making Twenty Fourteen Wider

We spent yesterday figuring out how to get rid of all the green in 2014 and set up a new colour. I like the looks of that, but there is still one more thing bugging me. I’ve had several posts over the years about the same thing. I don’t like how narrow things are in the theme! Well, here’s a quick fix to change that!

I only just set this up and haven’t thoroughly tested every little detail. Everything looks good to me right now, but as always, if you find I missed something feel free to leave me a comment and I’ll get adjust my code on here!

There’s just a little thinking to do here, we need to come up with our numbers. I’ll give you the defaults along with my changes and you can make your own decisions. Now a bit of a disclaimer again, I’m almost certain there is some ratios and formulas that were used in the development of the original theme – I didn’t use any. I just set things where I wanted them and guessed at the rest. That 786px for hentry is the width I needed to make sure my featured images touched up against the left sidebar – I found this number through trial and error to be honest (I had started at 752, but th eimage had a gap, so I increased until it was perfect). It looks good right now, but there might be slight adjustments needed to my numbers.

  • The overall default maximum width is 1260px, I increased this to 1420px
  • The content area (hentry) column is 672px, I increased this to 786px
  • The actual content is 474px, I increased this to 654px

So now I just cruised through the CSS looknig for any of the default entries and changing them to mine. Here’s what I came up with:

.site {
	max-width: 1420px;
}

.site-header {
	max-width: 1420px;
}

.hentry {
	max-width: 786px;
}

.site-content .entry-header,
.site-content .entry-content,
.site-content .entry-summary,
.site-content .entry-meta,
.page-content {
	max-width: 654px;
}

.post-navigation,
.image-navigation {
	max-width: 654px;
}

.archive-header,
.page-header {
	max-width: 654px;
}

.contributor-info {
	max-width: 654px;
}

.comments-area {
	max-width: 654px;
}

.site-main .mu_register,
.widecolumn > h2,
.widecolumn > form {
	max-width: 654px;
}

That goes into your child theme’s style.css file under the @import line (if you are unfamiliar with child themes, see my writeup here). You can save that and refresh your page to check it out. It looks pretty good, but we have one more thing to take care of.

In your child theme’s functions.php file you will need to add this

$content_width = 654;

// CHANGE DEFAULT THUMBNAIL SIZE
function voodoo_twentytwelve_setup() {
	set_post_thumbnail_size( 786, 410, true );
}
add_action( 'after_setup_theme', 'voodoo_twentytwelve_setup', 11 );

somewhere after the opening php tag. This takes care of adjusting the thumbnail/featured image as well as any embeds. Feel free to tweak that image height of 410 to suit your needs.

There we go with another quick tweak. Everything looks good on my end so far! So, do you plan on adjusting anything with the 2014 theme? Did I miss something? Feel free to let me know in the comments!

Monitor Your Website(s) From Google Docs, and Find Out Some Very Interesting Things!

I came across a couple of posts recently which showed me how to monitor my website uptime using Google Docs. They both work great, one is for a single site. That is suffucient for many users, and you can use multiple copies, 1 to monitor each site. The next one is inspired by the first, but allows for multiple sites in a single sheet. These are fantastic tools that set up easily. Check it out:

All I did was follow the simple instructions. I’ve tested both, and both work perfectly, so just pick one based on your preferences. Set it up, and run it. Here’s what it looks like (on my phone anyway):

Here’s the downside of this. It showed my just how often my sites were going down. A minute here, a minute there. Several times going down for 15 or 20 minute blocks. The sheets keep a running log of up and down times for you too, plus you get emails whenever your sites go up or down.

I definitely recommend you play around with this… it just might drive you to a new host!

Customizing Twentyeleven, Let’s Start With Width and Smaller Header

I dig twentyeleven. It’s got a lot of fun features and it looks pretty good. There were a couple of things I didn’t like, however. The header is kind of GIANT. So I’m going to need to take care of that. Also, although it is flexible width, the maximum width was a bit too narrow for my taste. Also, I need wider sidebars, I don’t like things looking so cramped over there. While I’m messing with the header, I have my own logo for VoodooPress, no need for the site name to be up top. I’m going to get rid of that, and while I’m at it relocate the search and site description to overlay my header image. Finally, I like my widgets to have their own home, they need a nice box to seperate them from the content a little. It’s pretty easy to get this all done, check it out!

So the first thing I need to do, is to widen the max-width of the theme. You’ll notice some extra css in some of my examples. I also reduced margins in some places. Twentyeleven had too much white space for my taste. Some people love it that way, but hey, this is what I like! Before we get into this too far, make sure you have your child theme set up. If you forget how, run over here and check it out. Just remember, that tutorial is for twentyten. You’ll have to just adjust the header and import rule to refer to twentyeleven.

Here’s where the theme width is set up in twentyeleven’s style.css:

/* =Structure
----------------------------------------------- */

body {
	padding: 0 2em;
}
#page {
	margin: 2em auto;
	max-width: 1000px;
}

Really all you need to do there is adjust the max-width in #page. Here’s my final view:

#page {
	margin: 1.5em auto;
	max-width: 1050px;
	border-top: 15px solid #bbb;
	-webkit-border-radius: 15px;
	-moz-border-radius: 15px;
	-o-border-radius: 15px;
	border-radius: 15px;
}

Honestly, that’s it. You’ll see I have some extra stuff in there. I tweaked the margin to reduce the gutters on the side, and I added a think rounded border to the top. That’s just for my visual taste, When I remove all the info from above the header image, it looked a bit harsh. I liked the idea of just a little visual interest up top.

So with that out of the way, I realized that with a wider theme, I’d need a wider header image. This is super simple. I just made a functions.php file in my child theme and added (NOTE: this is new update code to add a filter, which is the preferred way to do this):

//CUSTOM HEADER SIZE
add_filter( 'twentyeleven_header_image_height', 'voodoo_header_height');
function voodoo_header_height($param) {
return 175;
}
add_filter( 'twentyeleven_header_image_width', 'voodoo_header_width');
function voodoo_header_width($param) {
return 1050;
}

For informational purposes, below is the old function I used to adjust the header image. It worked, but one of our readers pointed out in the comments that we weren’t using the best method. So I recommend you use the above code, the code below is just kept for comparison.

//CUSTOM HEADER SIZE
add_action( 'after_setup_theme', 'voodoochild_theme_setup' );

if ( !function_exists( 'voodoochild_theme_setup' ) ):
function voodoochild_theme_setup() {
	define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyeleven_header_image_height', 175 ) );
	define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyeleven_header_image_width', 1050 ) );
}
endif;

Don’t forget the opening php tag at the top if you are started a brand new functions.php file. OK, now with that above function I’ve altered twentyeleven’s header image from 1000x288px to a wider and shorter 1050x175px. Of course you can just do the width and leave the height line out, or use different values.

With the new header image in place, any new header you upload either through the header menu, or using the featured image uploader will be in that size. But I’ve had VoodooPress going for a bit, and it used to use twentyten, which had different header sizes. Chances are your site will not look right if you already have posts with thumbnails. No problem, I’ve got you covered! Check out this handy plugin here. It’ll regenerate your thumbnails and get everything looking so good once again.

One final thing I needed to deal with to get my headers to work properly. Sometimes I like to use images that are smaller than the header. By default if you do that, it won’t be used as your header image. Well, I copy header.php from twentyeleven and put it into my theme. I need to tweak some things further on it, so I need my own copy used. I found this bit of code toward the bottom of header.php:

	has_post_thumbnail( $post->ID ) &&
	( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( HEADER_IMAGE_WIDTH, HEADER_IMAGE_WIDTH ) ) ) &&
	$image[1] >= HEADER_IMAGE_WIDTH ) :
// Houston, we have a new header image!

I just deleted

&&
							$image[1] >= HEADER_IMAGE_WIDTH

So I was left with:

	has_post_thumbnail( $post->ID ) &&
	( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT ) ) ) ) :
// Houston, we have a new header image!

And that allows for featured images smaller than the minimum size to still be used. So we are getting pretty close to good here. We’ve got a wider theme, a wider header image to fit the theme and more options for our header image size. Tomorrow, we’ll finish this off. Tweaking the rest of the white space, readjusting the header some more, and prettying up the widget areas. After that, I’ll post up my header.php and style.css code in case I forgot anything, so you can peep my finished product so far. Once I have myself a nice basic child theme done to my liking, it’ll be time to look for new fun to be had.

Configuring Contact Form 7 to Work Perfectly With a Twentyten Child Theme

I needed a contact form for VoodooPress.  Normally I use cforms.  It’s very powerful, but it seemed like too much for a simple form.  I decided to give the Contact Form 7plugin a try this time.  I came across a few challenges getting it set up perfectly with my twentyten child theme.  But it was a cool learning experience.  Let’s take a look at what I did.  A lot of this information may help you on themes besides twentyten as well, it’s just focused on that.

Just a note, something is happening to the displayed code below that I can’t figure out. Certain bits of code are being parsed into the number 1. Where you see that, all that is missing is the bit of code from the CF7 plugin which displays the field. I hope you can still follow along with this.

Obviously the first step here is to install and activate the plugin.  Then go ahead and set up your form.  You can stick with the default, or you can make your own.  I’m not going to go into a lot of detail on configuring the form, as there is plenty of info on their website about that. But one thing to note is that you may wish to change the layout of your form a little. I really didn’t like the default layout. Here is the code you are given:

<p>Your Name (required)<br />
     </p>

<p>Your Email (required)<br />
    [email* your-email] </p>

<p>Subject<br />
     </p>

<p>Your Message<br />
    [textarea your-message] </p>

<p>[submit "Send"]</p>

It didn’t seem all that semantic to me, so I went ahead and redid it. You really only need to keep the stuff in square brackets, the rest is up to you. So here is the above form layed out again in a manner I prefer.

<fieldset class="name">
 
<label>Your Name (required)</label>
</fieldset>

<fieldset class="email">
 [email* your-email]
<label>Your Email (required)</label>
</fieldset>

<fieldset class="subject">
 
<label>Subject</label>
</fieldset>

<fieldset class="message">
 [textarea your-message]
<label>Your Message</label>
</fieldset>

<fieldset class="submit">
 [submit "Send"]
</fieldset>

Of course you don’t need to follow along with that, I just wanted to show you that you are free to code away in the plugin’s form edit area as much as you like. Also, the classes aren’t necessary on the fieldsets, it can just say fieldset. I put them there out of habit in case I want to to style each later down the road. I don’t even use them right now.

After I set up the form, I noticed the layout completely sucked to put it mildly. We have 3 major problems here for controlling our own layout. Even though we are using a child theme of twentyten, twentyten’s form css is acting on our form. Also, Contact Form 7 has it’s own styling. And finally there is an autop feature, which adds paragraph and linebreaks into the source.

The first thing I wanted to do was get rid of twentyten’s influence. This is quite easy. There are many ways to accomplish the same thing here, but the goal is to make sure the form you put on your page is no longer inside of the entry-content div class. The easiest way I thought was to make a page template. If you aren’t familiar with page templates, read up! They are very useful. This page template is a combination of twentyten’s (from WP 3.1) page.php and loop-page.php. I just combined everything into one file. I only changed one line here. I changed the div class=entry content here:

				<h1 class="entry-title"><?php the_title(); ?></h1>
			<?php } ?>

			<div class="entry-content">
				<?php the_content(); ?>

To read div class=”form-content”. I am using this page only for the contact form, so I just needed to get rid of entry-content as twentyten styles forms within entry-content. If I am not being too clear, or you just wanna see what I did, take a look at the full template

<?php
/*
Template Name: Contact Form
*/
get_header(); ?>

		<div id="container">
			<div id="content" role="main">

<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>

				<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
					<?php if ( is_front_page() ) { ?>
						<h2 class="entry-title"><?php the_title(); ?></h2>
					<?php } else { ?>
						<h1 class="entry-title"><?php the_title(); ?></h1>
					<?php } ?>

					<div class="form-content">
						<?php the_content(); ?>
						<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
						<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="edit-link">', '</span>' ); ?>
					</div><!-- .entry-content -->
				</div><!-- #post-## -->

				<?php comments_template( '', true ); ?>

<?php endwhile; // end of the loop. ?>

			</div><!-- #content -->
		</div><!-- #container -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

You can just save that as a new file in your child theme called contact.php, and apply it to a page, and you have solved a big part of your styling problem.

Next up is Contact Forms 7 styling. We can get rid of that super easily. Just plop this down into your functions.php:

//DEREGISTER CONTACT FORM 7 STYLES
add_action( 'wp_print_styles', 'voodoo_deregister_styles', 100 );

function voodoo_deregister_styles() {
	wp_deregister_style( 'contact-form-7' );
}

Now if you plan to let Contact Forms 7 handle your styling, that’s cool. But I wanted to do my own. And yes, I will share that with you shortly as well. But remember, after the previous 2 steps, you will have no css on your form. It’ll look narsty. But that’s cool. Let’s fix the last problem and then you can get to work on styling. I’ll show you my own css for my form, chock full of css3 goodness.

OK, now twentyten’s default form styling doesn’t have us in it’s clutches. And we are free of Contact Form 7’s default styling. Why does the form still seem like it has some styling? It’s because there is an autop feature that automatically inserts paragraph and line breaks into your source code. If you view your output source from within the browser, you’ll see em. Let’s get ’em! You’ll need to use ftp or a file manager with your host to accomlish this step. We are going to edit wp-config.php. My rule here, never touch this file without backing it up first. Got it backed up? Good! You just need to scroll down and find the stop editing happy bloggin line towards the bottom, and add one line of code above that line so it looks like this:

define ('WPCF7_AUTOP', false );   // set to false to remove <br> tags

/* That's all, stop editing! Happy blogging. */

And that my friends is it as far as stripping away outside influences off of your Contact Form. If you check out your form now, you’ll truly hate it. No styling at all! Well, you are now free to add your own styling to your child theme’s style.css, and have it actually work as you expected. Wanna peek at mine? Sure thing! Like I said earlier, it’s chock full of CSS3 goodies. Shadows, Alphas, Gradients, even animations for webkit browsers. I feel they are a good combination of bold but not over the top. If you haven’t played around with CSS3 yet, there’s good news. Everything degrades nicely for browsers that don’t support it yet. It is very cool on the ones that do, and it looks like a nice clean form on browsers like IE. You can see it yourself on my contact page. Anyway, here’s my css, please note, this will only work if you laid out your form as I did above! You can have different itmes than I do of course, I actually have many more than that. Just the layout style needs to match.

/* CONTACT FORM 7 SPECIFIC STUFF*/
.wpcf7 {
	margin-left: 50px;
	background: #9e9786;
	background: rgba(158, 151, 134, 0.6);
	padding: 15px;
	border: none;
	-webkit-border-radius: 7px;
	-moz-border-radius: 7px;
	-o-border-radius: 7px;
	border-radius: 7px;
}
.wpcf7-form fieldset {
	margin: 0 0 10px 0;
}
.wpcf7-form fieldset label {
	display: block;
	font-weight: bold;
	line-height: 1.4;
	color: #666;
	color: rgba(0, 0, 0, 0.6);
	text-shadow: 0 1px 1px #fff;
	margin-left: 10px;
}
.wpcf7-form fieldset:last-child {
	margin: 0;
}
.wpcf7-form fieldset input[type="text"],
.wpcf7-form fieldset textarea {
	width: 215px;
	padding: 5px 8px;
	font-size: 1.2em;
	color: #666;
	border: none;
	background-image: -webkit-gradient(linear, 0% 0%, 0% 12%, from(#999), to(#fff));
	background-image: -moz-linear-gradient(0% 12% 90deg, #fff, #999);
	background: #FFFFFF url('images/grad.jpg') left top repeat-x;
	box-shadow: rgba(0,0,0, 0.1) 0px 0px 8px;
	-moz-box-shadow: rgba(0,0,0, 0.1) 0px 0px 8px;
	-webkit-box-shadow: rgba(0,0,0, 0.1) 0px 0px 8px;
	-webkit-border-radius: 4px;
	-moz-border-radius: 4px;
	-o-border-radius: 4px;
	border-radius: 4px;
}
.wpcf7-form fieldset textarea {
	width: 430px;
}
.wpcf7-form input[type="submit"] {
	padding: 8px 15px;
	font-family: Helvetica, Arial, sans-serif;
	font-weight: bold;
	line-height: 1;
	color: #444;
	border: none;
	text-shadow: 0 1px 1px rgba(255, 255, 255, 0.85);
	background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#fff), to(#bbb));
	background-image: -moz-linear-gradient(0 100% 90deg, #fff, #bbb);
	background: #FFFFFF url('images/grad.jpg') left top repeat-x;
	-webkit-border-radius: 23px;
	-moz-border-radius: 23px;
	-o-border-radius: 23px;
	border-radius: 23px;
	-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
	-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
.wpcf7-form fieldset input[type="text"]:focus, .wpcf7-form fieldset textarea:focus,
.wpcf7-form fieldset input[type="text"]:hover, .wpcf7-form fieldset textarea:hover {
	border: 1px solid #401f1f;
	-webkit-box-shadow: 0 0 12px rgba(64, 31, 31, 0.5);
	-moz-box-shadow: 0 0 12px rgba(64, 31, 31, 0.5);
	box-shadow: 0 0 12px rgba(64, 31, 31, 0.5);
}
@-webkit-keyframes pulse {
	0% {
		-webkit-box-shadow: 0 0 12px rgba(64, 31, 31, 0.2);
	}
	50% {
		-webkit-box-shadow: 0 0 12px rgba(64, 31, 31, 0.9);
	}
	100% {
		-webkit-box-shadow: 0 0 12px rgba(64, 31, 31, 0.2);
	}
}
.wpcf7-form fieldset input[type="text"]:focus,
.wpcf7-form fieldset textarea:focus {
	-webkit-animation: pulse 1.5s infinite ease-in-out;
}
.wpcf7-form fieldset input[type="submit"]:hover,
.wpcf7-form fieldset input[type="submit"]:focus {
	-webkit-animation: pulse 1.5s infinite ease-in-out;
}

That was an eyefull eh? A lot of cool stuff on there to check out. Google is your friend if you don’t know much about CSS3 or styling forms. It’s where I learned everything. And a little note, my css will style all Contact Form 7 forms cross site. If you want to target individual forms, you will need to swap out .wpcf7-form for the form specific ID you get for each form. You can see it in your browser source.

That’s it for cleaning up CSS influences and getting your form styled. As a little bonus for those of you who stuck around to the very end, here’s a performance improvement. By default, Contact Form 7 loads it’s javascript on every page. We don’t need it loading if there is no form on the page. Check out this little snippet for your functions.php file:

//DEREGISTER CONTACT FORM 7 SCRIPTS ON ALL PAGES WITH NO FORM
add_action( 'wp_print_scripts', 'voodoo_deregister_javascript', 100 );
function voodoo_deregister_javascript() {
	if ( !is_page('contact-us') ) {
		wp_deregister_script( 'contact-form-7' );
	}
}

That works for me. It only loads the scripts on my contact form page, which is named ‘contact-us’. You’ll obviously need to swap that out for your page name. If you have more than one page, that’s cool, just be sure to put them in an array, like:

//NOTE this is just one line from the above block to illustrate using the array
if ( !is_page( array('contact-us', 'contact-them', 'contact-someone-else') ) ) {

And that’s it. There you have the ins and outs of Contact Form 7 and using it in a twentyten child theme. I hope you learned something. I know I did today!

Seperate Lines out of a Multi-Line Custom Field Value

I ran into an interesting problem today. My podcasting plugin over on my blog flaked out on an upgrade. The music player still works, but the download links disappeared. Now that site relies on the music downloads. I just couldn’t have that. The developers are looking for a fix, but I needed the functionality now. So I came up with a nifty band-aid.

The first thing I did was look at how the music was included into my post. I fill out a little form on the backend and the music gets inserted into my posts, with a player, and links and everything. Well I noticed that this was all done with a custom field. Once I entered my music information and saved the post, a custom field was created called enclosure. This enclosure has enclosed in the value all the information to make everything work. My gut instinct was to just echo out

get_post_meta($post_id, $key, $single);

inside of an a href link to make it work. But I had a problem. The value was actually set up like this:

url to media
size of file
type of file
encoding info

We had multiple lines of data. I originally thought that if I set the $single value to true, it would only echo out the first line. You can read about the $single value, and all about custom fields here. Well, that isn’t the case. The $single set to true only grabs the first value if you have multiple key value pairs with the same key. I had a multi-line value, and only needed the first line, the url to the media.

So I did a fair bit of googling, and came across this article. This article showed me that if I have a multi-line value set up, I can include

$items = get_post_meta($post->ID, 'ItemInfo');

in my loop to grab the entire value.

It would then return that all in an array, which I could break up in a foreach loop, breaking apart the multi-line value by enforcing the line breaks that are in the custom field value. The example code given on that site looks like:

foreach($items as $item) {

$item = nl2br($item);
list($name,$src,$price,$desc) = explode('<br />',$item);

echo "<div class="item">";
echo "<h2>$name</h2>";
echo "<img src="".trim($src)."" />";
echo "<br />Price: $price";
echo "<br />Description: $desc";
echo "</div><br />";

}

If you look at the link I provided, it will make a lot more sense, I’m just summarizing here. Now I didn’t need all the info output. I just needed the first line output (the media url) as a download link. So I took that example code given, and tweaked it for my own use. Here’s what I came up with real quick:

	<?php if( get_post_meta($post->ID, "enclosure", true) ): ?>
		<?php $items = get_post_meta($post->ID, 'enclosure'); ?>
		<?php foreach($items as $item) {

			$item = nl2br($item);
			list($name,$src,$price,$desc) = explode('<br />',$item);

			echo "<a href="$name">Download</a>";
			} ?>
	<?php endif; ?>

And it worked perfectly. We set up on line 1 to only do the code if the enclosure key actually exists. Then on line two we grab the values associated with enclosure key, and spit it out in an array. We break each line down on a line break and assign it to a variable. And then I only needed the first line, which is assigned to $name, so I just spit out $name inside of a link.

I know this will come in handy in the future for me. So I just wanted to share the info with you in case you run into a similar situation. My downloads work again until the plugin is fixed, and I’m happy!

Review of Posting From Front End Form

Over the past three days we’ve accomplished quite a bit. First we set up a form to post from the front end. Once we had the form all set up, we dropped in some code to allow images to be uploaded with the form. And finally we added in the ability to use custom meta boxes on our form to collect additional information in custom fields for us to use. That’s a lot of code. Plus I had some difficulties with code that sometimes worked and sometimes did not. I got that all fixed. I thought it might be best to drop the full code I have in one post so that we can review it together.

So let’s take a look at the code. Now I’m pretty much just going to drop what I have here for you to look at it. I’m not going to spend too much time explaining it. If you have questions you can always go back to the original posts that are all linked above. So first off let’s take a look at the main form page. Now remember that I use a twenty ten child theme. So my code will reflect that. Your’s may be slightly different depending on what theme you use. If you recall I made a page template, kept in a basic loop, and added in my form and processing code. Here is the complete final results of that:

<?php
/*
Template Name: Rate Wine Form
*/
?>
<?php
if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) &&  $_POST['action'] == "new_post") {

	// Do some minor form validation to make sure there is content
	if (isset ($_POST['title'])) {
		$title =  $_POST['title'];
	} else {
		echo 'Please enter the wine name';
	}
	if (isset ($_POST['description'])) {
		$description = $_POST['description'];
	} else {
		echo 'Please enter some notes';
	}

	$tags = $_POST['post_tags'];
	$winerating = $_POST['winerating'];

	// ADD THE FORM INPUT TO $new_post ARRAY
	$new_post = array(
	'post_title'	=>	$title,
	'post_content'	=>	$description,
	'post_category'	=>	array($_POST['cat']),  // Usable for custom taxonomies too
	'tags_input'	=>	array($tags),
	'post_status'	=>	'publish',           // Choose: publish, preview, future, draft, etc.
	'post_type'	=>	'post',  //'post',page' or use a custom post type if you want to
	'winerating'	=>	$winerating
	);

	//SAVE THE POST
	$pid = wp_insert_post($new_post);

             //KEEPS OUR COMMA SEPARATED TAGS AS INDIVIDUAL
	wp_set_post_tags($pid, $_POST['post_tags']);

	//REDIRECT TO THE NEW POST ON SAVE
	$link = get_permalink( $pid );
	wp_redirect( $link );

	//ADD OUR CUSTOM FIELDS
	add_post_meta($pid, 'rating', $winerating, true);

	//INSERT OUR MEDIA ATTACHMENTS
	if ($_FILES) {
		foreach ($_FILES as $file => $array) {
		$newupload = insert_attachment($file,$pid);
		// $newupload returns the attachment id of the file that
		// was just uploaded. Do whatever you want with that now.
		}

	} // END THE IF STATEMENT FOR FILES

} // END THE IF STATEMENT THAT STARTED THE WHOLE FORM

//POST THE POST YO
do_action('wp_insert_post', 'wp_insert_post');

?>

<?php get_header(); ?>

		<div id="container">
			<div id="content" role="main">

<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>

				<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
					<?php if ( is_front_page() ) { ?>
						<h2 class="entry-title"><?php the_title(); ?></h2>
					<?php } else { ?>
						<h1 class="entry-title"><?php the_title(); ?></h1>
					<?php } ?>

					<div class="form-content">
						<?php the_content(); ?>

		<!-- WINE RATING FORM -->

		<div class="wpcf7">
		<form id="new_post" name="new_post" method="post" action="" class="wpcf7-form" enctype="multipart/form-data">
			<!-- post name -->
			<fieldset name="name">
				<label for="title">Wine Name:</label>
				<input type="text" id="title" value="" tabindex="5" name="title" />
			</fieldset>

			<!-- post Category -->
			<fieldset class="category">
				<label for="cat">Type:</label>
				<?php wp_dropdown_categories( 'tab_index=10&taxonomy=category&hide_empty=0' ); ?>
			</fieldset>

			<!-- post Content -->
			<fieldset class="content">
				<label for="description">Description and Notes:</label>
				<textarea id="description" tabindex="15" name="description" cols="80" rows="10"></textarea>
			</fieldset>

			<!-- wine Rating -->
			<fieldset class="winerating">
				<label for="winerating">Your Rating</label>
				<input type="text" value="" id="winerating" tabindex="20" name="winerating" />
			</fieldset>

			<!-- images -->
			<fieldset class="images">
				<label for="bottle_front">Front of the Bottle</label>
				<input type="file" name="bottle_front" id="bottle_front" tabindex="25" />
			</fieldset>

			<fieldset class="images">
				<label for="bottle_rear">Back of the Bottle</label>
				<input type="file" name="bottle_rear" id="bottle_rear" tabindex="30" />
			</fieldset>

			<!-- post tags -->
			<fieldset class="tags">
				<label for="post_tags">Additional Keywords (comma separated):</label>
				<input type="text" value="" tabindex="35" name="post_tags" id="post_tags" />
			</fieldset>

			<fieldset class="submit">
				<input type="submit" value="Post Review" tabindex="40" id="submit" name="submit" />
			</fieldset>

			<input type="hidden" name="action" value="new_post" />
			<?php wp_nonce_field( 'new-post' ); ?>
		</form>
		</div> <!-- END WPCF7 -->

		<!-- END OF FORM -->
						<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
						<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="edit-link">', '</span>' ); ?>
					</div><!-- .entry-content -->
				</div><!-- #post-## -->

				<?php comments_template( '', true ); ?>

<?php endwhile; // end of the loop. ?>

			</div><!-- #content -->
		</div><!-- #container -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

So that form has code from all three tutorials in it. It has the basic post from front end form. It has the code in place for allowing image uploads. It also has the custom field meta box code in it. The next bit of code we need goes in functions.php. This is the bit for allowing the image uploads.

function insert_attachment($file_handler,$post_id,$setthumb='false') {
	// check to make sure its a successful upload
	if ($_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK) __return_false();

	require_once(ABSPATH . "wp-admin" . '/includes/image.php');
	require_once(ABSPATH . "wp-admin" . '/includes/file.php');
	require_once(ABSPATH . "wp-admin" . '/includes/media.php');

	$attach_id = media_handle_upload( $file_handler, $post_id );

	if ($setthumb) update_post_meta($post_id,'_thumbnail_id',$attach_id);
	return $attach_id;
}

That’s it for the posting bit. I’ll add in a couple more bits of code, the stuff you need for displaying the extra stuff in the form. For instance the images in my form will upload and attach to the post, and the last image becomes the featured image. But the images attached to the post are not set to display. Here’s the code that goes in your loop to actually display the images:

<div class="wineBottles">
<?php
$args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID );
$attachments = get_posts($args);
if ($attachments) {
	foreach ( $attachments as $attachment ) { ?>
		<div class="wineImage">
			<span class="wineTitle">
		<?php echo apply_filters( 'the_title' , $attachment->post_title ); ?>
			</span>
		<?php the_attachment_link( $attachment->ID , false ); ?>
		</div>
	<?php }
}
?>
</div>

As I said before, there is some various css selectors added in there. You’ll need to swap them out, or define them in your css. I won’t be getting into styling stuff in this tutorial as that’s a matter of personal preference. Finally we need the bit of code for displaying the data from the custom field in the form. This also goes in your loop, wherever you want the data output. You’ll need to change this up to make use of your data however you need it, this is a very basic example:

				<div class="wineRating">
				<?php if( get_post_meta($post->ID, "rating", true) ): ?>
				<?php echo get_post_meta($post->ID, "rating", true); ?>
				<?php endif; ?>
				</div>

And that is all of it. Every bit of code I’ve used so far to get my post from front end form working properly. I hope this helps you out some. Now take this and run with it, you can do so much stuff once you understand how this all works.

UPDATE: @trusktr helped me out by leaving a comment over on the wordpress answers site. I haven’t had a chance to play with this yet, but wanted to get it up here asap for users playing around with this form. Trusktr reports that in the validation code at the top changing:

 isset ($_POST['description'])

 to

$_POST['description'] != ''

Solves our problems and stops the form from posting when it should not. If anyone messes around with this, let us know how it works out!

WordPress 3.1 Admin Bar Upgrade Issues

Well, WordPress 3.1 has been out in the wild for hours now.  I’m seeing the support requests trickle in, and there is already a very common issue.  A strange white gap at the top of the page where the admin bar should be.  Let’s fix that, or conversely, if you have the admin bar and hate it, let’s get rid of it!

First up, the mysterious missing admin bar, leaving just a gap at the top of your page.  Now remember, the admin bar only shows when you are logged in.  But if you are logged in and just see a blank space with no admin bar, chances are you are missing your wp_footer call.  Simple fix, add it in footer.php on the line above your closing body tag, so your footer.php should end like:

          <?php wp_footer(); ?>
     </body>
</html>

On the flip side of this problem is the wp_head call. This may surprise you, but that one goes up in your header.php file! Take a look, it should be right before the closing heade tag, or real close. It may not be at the very bottom of your header.php file itself, as often there is body content in your header. Your header image, your navigation, etc. But somewhere in your header.php file you should see:

<?php wp_head(); ?>
</head>

I’m amazed this is affecting so many people. That wp_footer and wp_head calls are vital for so many things. Anyway, get that in there and you should be all set. Now what if you hate the admin bar. Well for one, you can set it up in your user profile page. Turning it on or off for the front or back end. Or you can drop this into functions.php to kill it altogether:

//REMOVE ADMIN BAR
remove_action('init', 'wp_admin_bar_init');

I’ve also seen this code for removing the admin bar (I trust the author of this solution, so I’d try this one first):

/* Disable the Admin Bar. */
add_filter( 'show_admin_bar', '__return_false' );

Either way it gets added to functions.php. (or mu-plugins for site wide on multisite, you’ll remember that from this article)

And there you have it. 2 Admin Bar problems resolved! If you have other problems with the admin bar, or found this topic looking for general problems with a 3.1 upgrade, please check out this link on the forums. It’s a master list being kept of problems and solutions.

I See get_template_part in my WordPress Theme. What’s it For? How Do I Use It?

I have seen quite a few searches come through lately for get_template_part.  Seems like a lot of folks don’t know what it’s for, what it does, or how to use it in their WordPress theme.  When it was introduced with WordPress version 3.0 I wasn’t all that excited.  I didn’t see a need for it.  I was kind of set in my ways.  I liked how I did things.  But after looking into it for a while, I discovered it’s a powerful and useful tool.  Let’s take a look at what it does for you.

First off, what is it?  Simply put, get_template_part is just a way to include another file.  But it’s more powerful than a php include statement, because of its flexibility.  It’s amazingly useful, especially for anyone trying to build a child theme.  So let’s take a look at how it could work for you if you are trying to make a child theme for twentyten first.  If we look at index.php in twentyten, we see:

get_template_part( 'loop', 'index' );

What’s that do?  Well let’s take a look at the structure.  Get template part follows the format of:

get_template_part( $slug, $name );

Where the slug is the generic name of the template being called, and name is the specialized name of the template being called.  So there is an order that WordPress would use to try to find the template to use.  Properly named files in your child theme come first, then files in your parent theme are used.  So using the example above with the generic name ‘loop’ and the specialized name ‘index’ here is the order WordPress would look for files.

  1. wp-content/themes/twentytenchild/loop-index.php
  2. wp-content/themes/twentytenchild/loop.php
  3. wp-content/themes/twentyten/loop-index.php
  4. wp-content/themes/twentyten/loop.php

See how that works?  We look for the specialized template in your child theme.  Then the generic.  Then the specialized name in the parent template.  Finally the generic name in the parent theme.

Now sticking with the twentyten theme. We already know we have this in index.php:

get_template_part( 'loop', 'index' );

And we also can see we have this in archive.php:

get_template_part( 'loop', 'archive' );

So what does it all do?  Well, in a basic twentyten install, there are no specialized templates, nothing named loop-index.php or loop-archive.php, so WordPress simply uses loop.php.  But the power comes in here for you, the child themer!  You could overwrite the loop for the index page or the archive page by creating the specialized named file loop-index.php or loop-archive.php.  For instance, if you only made a loop-index.php, then your file would be used for the main index page.  But since you didn’t make a loop-archive.php, twentyten’s original loop.php file would be used.  You see, you can override either template, without affecting the other.  Now if you made a file called just loop.php in your child theme, with no specialized template, then your loop.php would override twentyten’s for both situations.

Hopefully now you can see the naming conventions. How it all works, and how you can override templates in themes which use get_template_part. It gives you a lot of power when making a child theme. But what if you are making your own theme? How can you use it? Well you could a couple of routes here. In all your files (index.php, archive.php, category.php, etc) You could make a call to get_template_part, and make an individual file for each loop. So index.php would have:

get_template_part( 'loop', 'index' );

And then you would make a file called loop-index.php with the loop in it. You could do that for each file. This now gives anyone trying to make a child theme for your theme a way to override your loops. Or you can do what I like. Use get template part in your theme, but just make a loop.php file and code it to account for everything. I have a giant loop.php which uses a variety of conditional statements to cover all my templates. It handles index, archive, my shop, pages, single view, custom post types, etc. I just built the file up as I added everything. So now I have one big loop, but have given users of my theme the ability to use their own loops with get_template_part.

You can also use get_template_part to call in things besides the loop. For instance I use:

get_template_part( 'icons', 'social' );

to call in a file called icons.php. It’s a big block of code that I use to display social icons under member profiles on my blog. Rather than repeat the code on various templates I just included it. This is nice for me as it allows me to reuse the block of code without actually typing it into each template. Keeps things neat and organized. But it also allows child themers to override it with their own code if they feel the need.

That’s it for this article. Hopefully it helped you understand what that bit of code is doing, and why get_template_part is so useful. Now get to building your own child theme, and have some fun with it!

Additional Post Formats For TwentyTen Child Theme, And Post Formats in General

EDIT: I recently found out a better way to add post formats to a Twenty-Ten child theme, scroll to the bottom of the post to check it out!

As we announced yesterday, WordPress 3.1 was released. Hopefully you have all upgraded by now. If not, get to it. Remember to always keep your install up to date with the latest release. Not just for the cool new features, but for security too. Anyway, if you recently upgraded to 3.1, you may be asking yourself the same question as I see others asking. Where are my post formats? WordPress 3.1 promised lots of different post formats, where are they? Let’s answer that question and tell you how to get them going if you don’t have them.

First thing to realize, post formats are a theme feature. Your theme needs to activate theme. So if you are using the TwentyTen theme, the only post formats available to you are Aside and Gallery (and Standard). But this isn’t too hard to remedy. We’re going to add in post format support for themes in general first. Then we will cover adding additional post formats to a twentyten child theme.

First up, the general stuff. Adding post formats to a theme is very easy to do. First visit the codex entry and decide which ones you would like to add from the available list. It’s simply one line of code added to you functions.php file:

//THEME SUPPORT FOR POST FORMATS
add_theme_support( 'post-formats', array( 'aside', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video', 'audio' ) );

You may not need or want them all. Here’s my line of thinking. I activate them all. I can assign posts to them if I want. I don’t have to style them all. But this way they are available. Down the road if I want to style them, my appropriate posts are already assigned to the formats. If I don’t style them, they look like normal posts, so nothing changes. And if I switch to a new theme that has these formats activated and styled, it’s like I planned ahead! Really the ones you activate and use are up to you.

OK, so that was the easy part. Now lets move on to adding additional formats to the twentyten theme by way of a child theme. If you’ve been following along with our customization tutorials so far for twentyten child themes, you know we already have a function set up to customize the header. Mine is called voodoochild_setup in the example, and it runs on after_setup_theme. For some reason just adding in additional post formats to this function doesn’t work. I tried and tried. So we have to do some copying from the twentyten theme here. We need to grab the entire twentyten_setup function from twentyten’s functions.php and copy it to our child theme. So take all this:

function twentyten_setup() {

	// This theme styles the visual editor with editor-style.css to match the theme style.
	add_editor_style();

	// Post Format support. You can also use the legacy "gallery" or "asides" (note the plural) categories.
	add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );

	// This theme uses post thumbnails
	add_theme_support( 'post-thumbnails' );

	// Add default posts and comments RSS feed links to head
	add_theme_support( 'automatic-feed-links' );

	// Make theme available for translation
	// Translations can be filed in the /languages/ directory
	load_theme_textdomain( 'twentyten', TEMPLATEPATH . '/languages' );

	$locale = get_locale();
	$locale_file = TEMPLATEPATH . "/languages/$locale.php";
	if ( is_readable( $locale_file ) )
		require_once( $locale_file );

	// This theme uses wp_nav_menu() in one location.
	register_nav_menus( array(
		'primary' => __( 'Primary Navigation', 'twentyten' ),
	) );

	// This theme allows users to set a custom background
	add_custom_background();

	// Your changeable header business starts here
	if ( ! defined( 'HEADER_TEXTCOLOR' ) )
		define( 'HEADER_TEXTCOLOR', '' );

	// No CSS, just IMG call. The %s is a placeholder for the theme template directory URI.
	if ( ! defined( 'HEADER_IMAGE' ) )
		define( 'HEADER_IMAGE', '%s/images/headers/path.jpg' );

	// The height and width of your custom header. You can hook into the theme's own filters to change these values.
	// Add a filter to twentyten_header_image_width and twentyten_header_image_height to change these values.
	define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 940 ) );
	define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 198 ) );

	// We'll be using post thumbnails for custom header images on posts and pages.
	// We want them to be 940 pixels wide by 198 pixels tall.
	// Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
	set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );

	// Don't support text inside the header image.
	if ( ! defined( 'NO_HEADER_TEXT' ) )
		define( 'NO_HEADER_TEXT', true );

	// Add a way for the custom header to be styled in the admin panel that controls
	// custom headers. See twentyten_admin_header_style(), below.
	add_custom_image_header( '', 'twentyten_admin_header_style' );

	// ... and thus ends the changeable header business.

	// Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
	register_default_headers( array(
		'berries' => array(
			'url' => '%s/images/headers/berries.jpg',
			'thumbnail_url' => '%s/images/headers/berries-thumbnail.jpg',
			/* translators: header image description */
			'description' => __( 'Berries', 'twentyten' )
		),
		'cherryblossom' => array(
			'url' => '%s/images/headers/cherryblossoms.jpg',
			'thumbnail_url' => '%s/images/headers/cherryblossoms-thumbnail.jpg',
			/* translators: header image description */
			'description' => __( 'Cherry Blossoms', 'twentyten' )
		),
		'concave' => array(
			'url' => '%s/images/headers/concave.jpg',
			'thumbnail_url' => '%s/images/headers/concave-thumbnail.jpg',
			/* translators: header image description */
			'description' => __( 'Concave', 'twentyten' )
		),
		'fern' => array(
			'url' => '%s/images/headers/fern.jpg',
			'thumbnail_url' => '%s/images/headers/fern-thumbnail.jpg',
			/* translators: header image description */
			'description' => __( 'Fern', 'twentyten' )
		),
		'forestfloor' => array(
			'url' => '%s/images/headers/forestfloor.jpg',
			'thumbnail_url' => '%s/images/headers/forestfloor-thumbnail.jpg',
			/* translators: header image description */
			'description' => __( 'Forest Floor', 'twentyten' )
		),
		'inkwell' => array(
			'url' => '%s/images/headers/inkwell.jpg',
			'thumbnail_url' => '%s/images/headers/inkwell-thumbnail.jpg',
			/* translators: header image description */
			'description' => __( 'Inkwell', 'twentyten' )
		),
		'path' => array(
			'url' => '%s/images/headers/path.jpg',
			'thumbnail_url' => '%s/images/headers/path-thumbnail.jpg',
			/* translators: header image description */
			'description' => __( 'Path', 'twentyten' )
		),
		'sunset' => array(
			'url' => '%s/images/headers/sunset.jpg',
			'thumbnail_url' => '%s/images/headers/sunset-thumbnail.jpg',
			/* translators: header image description */
			'description' => __( 'Sunset', 'twentyten' )
		)
	) );
}

And paste it into your functions.php in your child theme. I put it above my customized function for modifying the header. I recommend you do the same. Now here’s the thing. This is kind of a pain, since we made our custom function to override portions of this very function we are now placing into our child theme. But, this does give you options. Let’s talk about them.

You can just paste this twentyten_setup function in your child functions.php and edit the post formats portion and leave it at that. Your override custom function you made earlier will continue to work. That’s the route I took. Or you can delete your custom function and make those edits directly in the twentyten_setup now that it is in your child theme. You are able to add your default header image and tweak the sizes directly here. It’s up to you. Like I said I kept my custom function and just tweaked the format line.

To add new post formats, just edit line 7 to add in your own. I’m just going to add in a link post format. Here is my final code in my functions.php with twentyten_setup in place, with my post format added to it, and also with my custom voodoochild_setup in place with our previous customizations.

function twentyten_setup() {

	// This theme styles the visual editor with editor-style.css to match the theme style.
	add_editor_style();

	// Post Format support. You can also use the legacy "gallery" or "asides" (note the plural) categories.
	add_theme_support( 'post-formats', array( 'aside', 'gallery', 'link' ) );

	// This theme uses post thumbnails
	add_theme_support( 'post-thumbnails' );

	// Add default posts and comments RSS feed links to head
	add_theme_support( 'automatic-feed-links' );

	// Make theme available for translation
	// Translations can be filed in the /languages/ directory
	load_theme_textdomain( 'twentyten', TEMPLATEPATH . '/languages' );

	$locale = get_locale();
	$locale_file = TEMPLATEPATH . "/languages/$locale.php";
	if ( is_readable( $locale_file ) )
		require_once( $locale_file );

	// This theme uses wp_nav_menu() in one location.
	register_nav_menus( array(
		'primary' => __( 'Primary Navigation', 'twentyten' ),
	) );

	// This theme allows users to set a custom background
	add_custom_background();

	// Your changeable header business starts here
	if ( ! defined( 'HEADER_TEXTCOLOR' ) )
		define( 'HEADER_TEXTCOLOR', '' );

	// No CSS, just IMG call. The %s is a placeholder for the theme template directory URI.
	if ( ! defined( 'HEADER_IMAGE' ) )
		define( 'HEADER_IMAGE', '%s/images/headers/path.jpg' );

	// The height and width of your custom header. You can hook into the theme's own filters to change these values.
	// Add a filter to twentyten_header_image_width and twentyten_header_image_height to change these values.
	define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 940 ) );
	define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 198 ) );

	// We'll be using post thumbnails for custom header images on posts and pages.
	// We want them to be 940 pixels wide by 198 pixels tall.
	// Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
	set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );

	// Don't support text inside the header image.
	if ( ! defined( 'NO_HEADER_TEXT' ) )
		define( 'NO_HEADER_TEXT', true );

	// Add a way for the custom header to be styled in the admin panel that controls
	// custom headers. See twentyten_admin_header_style(), below.
	add_custom_image_header( '', 'twentyten_admin_header_style' );

	// ... and thus ends the changeable header business.

	// Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
	register_default_headers( array(
		'berries' => array(
			'url' => '%s/images/headers/berries.jpg',
			'thumbnail_url' => '%s/images/headers/berries-thumbnail.jpg',
			/* translators: header image description */
			'description' => __( 'Berries', 'twentyten' )
		),
		'cherryblossom' => array(
			'url' => '%s/images/headers/cherryblossoms.jpg',
			'thumbnail_url' => '%s/images/headers/cherryblossoms-thumbnail.jpg',
			/* translators: header image description */
			'description' => __( 'Cherry Blossoms', 'twentyten' )
		),
		'concave' => array(
			'url' => '%s/images/headers/concave.jpg',
			'thumbnail_url' => '%s/images/headers/concave-thumbnail.jpg',
			/* translators: header image description */
			'description' => __( 'Concave', 'twentyten' )
		),
		'fern' => array(
			'url' => '%s/images/headers/fern.jpg',
			'thumbnail_url' => '%s/images/headers/fern-thumbnail.jpg',
			/* translators: header image description */
			'description' => __( 'Fern', 'twentyten' )
		),
		'forestfloor' => array(
			'url' => '%s/images/headers/forestfloor.jpg',
			'thumbnail_url' => '%s/images/headers/forestfloor-thumbnail.jpg',
			/* translators: header image description */
			'description' => __( 'Forest Floor', 'twentyten' )
		),
		'inkwell' => array(
			'url' => '%s/images/headers/inkwell.jpg',
			'thumbnail_url' => '%s/images/headers/inkwell-thumbnail.jpg',
			/* translators: header image description */
			'description' => __( 'Inkwell', 'twentyten' )
		),
		'path' => array(
			'url' => '%s/images/headers/path.jpg',
			'thumbnail_url' => '%s/images/headers/path-thumbnail.jpg',
			/* translators: header image description */
			'description' => __( 'Path', 'twentyten' )
		),
		'sunset' => array(
			'url' => '%s/images/headers/sunset.jpg',
			'thumbnail_url' => '%s/images/headers/sunset-thumbnail.jpg',
			/* translators: header image description */
			'description' => __( 'Sunset', 'twentyten' )
		)
	) );
}


// VOODOOCHILD SETUP FUNCTION FOR ADJUSTING HEADER STUFF
function voodoochild_setup(){

// OVERRIDE TWENTYTEN HEADER SIZE
define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 1010 ) );
define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 228 ) );

// ADD IN OUR CUSTOM HEADER IMAGES TO DEFAULT
    $voodoochild_dir =    get_bloginfo('stylesheet_directory');
    register_default_headers( array (
        'voodoopress' => array (
            'url' => "$voodoochild_dir/images/voodoopress.jpg",
            'thumbnail_url' => "$voodoochild_dir/images/voodoopressthumb.jpg",
            'description' => __( 'VoodooPress Default', 'voodoochild' )
        )

    ));

}

add_action( 'after_setup_theme', 'voodoochild_setup' );

And that’s it. Our customized headers still work, and we have the link post format added. This is the only way I’ve found so far to make this work. If I find something better in the future, we will revisit this issue. Like I’ve stated before, I want to keep my copying and pasting from the parent theme to a minimum and just use actions, filters, or whatever wherever possible.

Don’t forget our article from a while back about organizing your functions.php. One thing you may want to do with that twentyten_setup is put it in its own file, and just include it near the top of your child functions.php.

Of course this only activates the formats. You still have tonnes of options for using/styling them. I have an article on my blog I wrote before starting VoodooPress explaining what I did. But here on this site, I reall only have edited style.css of my child theme to lend some styling to the formats. You have tonnes of options available which are beyond the scope of this particular article.

Whatever you do, play around, have fun, and we’ll tweak some more real soon!

UPDATE: I asked the question over on stack exchange, and I was right. There is a better and less code intensive way to do this. Let’s check it out. First off, we will leave our existing voodoochild_setup function alone. I have experimented with trying to adjust the priority of it, and that makes the existing code fail. So we will leave that alone and make a new code for functions.php:

add_action( 'after_setup_theme', 'voodoochild_formats', 11 );
function voodoochild_formats(){
     add_theme_support( 'post-formats', array( 'aside', 'gallery', 'link' ) );
}

You can see it looks just like the action we added earlier for voodoochild_setup. The only difference is the addition of the number 11. This changes the priority of our function to run after twentyten’s own twentyten_setup, so it overrides it. We can’t change the priority of voodoochild_setup to 11 and have it work though. So we simply have two different actions. But it’s far less code than bringing the entire twentyten_setup on board!