Create Sidebar Boxes with the Advanced Custom Fields Repeater

Use Advanced Custom Fields Repeater to create new sidebar boxes on your WordPress Website. This basically gives the user the ability to add custom sidebar boxes without getting into any code. Here’s what we are going to do. Give the ability to add a Title to the Box, Give it a Content Area, and the ability to choose what color the box will be.

This uses the Advanced Custom Fields Plugin – Free
And the ACF repeater plugin – $25 AUD

First we set up our Custom Fields. Go to Custom Fields, and add new. Let’s call this one “Sideboxes”
Screen Shot 2013-09-22 at 10.10.55 AM
Screen Shot 2013-09-22 at 10.10.37 AM
Then, “Add Field” and choose the repeater option at the bottom:
Screen Shot 2013-09-22 at 10.12.15 AM
Then click, “Add Sub Field”.
Create 3 Fields, one called:
“Title” and choose the text as your field type
“Contents” and choose the wysiwyg as your field type
“Color” and choose radio button as your field type. The enter, “green” “orange” “purple” as your radio choices.
Remember to choose your location to where you want the Repeater box to show, for example: pages, or a page template. And save.

Then we open up our sidebar.php template file and add a loop to pull the fields.


 	
 
		

Because the if statement is out side of any markup, the div will not show unless the fields have been field out on the page where your repeater is located. So let’s go through that process. Go to one of the pages that you located the Sideboxes on. Click “Add Row” in the new metabox that shows now that you created your new Custom Field.
Screen Shot 2013-09-22 at 10.21.36 AM
Fill in the Title, Contents and Choose your color and save the post or page.
Screen Shot 2013-09-22 at 10.22.58 AM
We have the markup, we have the contents, now we need style. Lets add some items to our css. We’ll add a green, purple and orange class to give our boxes some color.

.sideitem {
	width: 260px;
	padding:20px;	
	position: relative;
	float:left;
	color: #fff;
	margin-bottom: 15px;
}
.sideitem h3 {
	font-size: 18px;
	font-weight: 300;
	letter-spacing: 2px;
}
.green {background-color: #00845D;}
.purple {background-color: #565F98;}
.orange {background-color: #D56431;}

And with that, we have a new Sidebox in our sidebar!
Screen Shot 2013-09-22 at 10.28.35 AM