Now we have to add the code the for rest of the boxes in this Genesis Child Theme Options form.
Add a Description to the Form
But before we do that let’s add a description, p class=’description’. This is a class that Genesis uses and then I want to say “Choose the taxonomy, term and number of posts to display for each column below”.
Add Labels to the Columns
And I want to add a label to the columns. For this one I’m going to say Left Column Posts. Now we’ll copy this code and add it two more times for the other columns. So, we’ll paste it twice.
The first one was our Left Column Posts, second one is our Middle Column Posts. And here we need to change the box numbers all from box1 to box2. Then say Right Column Posts for the last one and replace all the box1 references with box3.
Then the only other thing we have to do is the same thing with this. So ‘box2_taxonomy’ and ‘box3_taxonomy’.
Review the Form
And now we should have our form setup. Let’s see what it looks like. Okay, the h2 is too big so we’ll change that to h3. That looks better. So “Choose the taxonomy, term and number of posts to display for each column below”.
Let’s try it out. Left Column Posts, category and we’ll choose Apples and 3. For this one we’ll choose Cherries and say 3. Save our settings. We know the settings saved properly if these are all chosen like this, that if they stay the way you just saved them then you know the settings were saved properly.
Complete Options Settings
Now what we have to do is use those settings in the rest of the loops. So control+H and we’re going to replace 1 with 3 and this one we’ll replace 1 with 2, replace all. Then same thing is true with this so now we’ve got $text2.
We probably want $text1_name there for that one $text2_name, $text3_name and $text3_name. So then here that’s $text1_name. Again, replace the 1 with a 3 and replace the 1 with a 2.
So we’ve got our options set up and now we’ve got all of our options. We’ve set whether it’s tag_id or cat and we’ve set up our arguments.
The only other thing I want to do here is I want to take the id which is term. I want to take the id and I want to get its name so we are going to look for get_term object. I need the $taxonomy, I need the $term, integer, $output is going to come out as an object.
So all we need to do here is get_term and then we will use $term->name. And while we’re here I may as well just say $label1=. Actually, that’s not the way it’s going to work. I think what we’re going to say is $term1_object=get_term() and then we’re going to get the term and we need the term_id which is going to be $term1 and we need the taxonomy which is $tax1.
Now we’ve got the term object and $label1=$term1_object->name. Then I’m going to take $label1 down here and instead of h2 Cherries I’m going to say and I can just do the same thing down here to the next 1, $label2 and $label3.
So we come back up here now and we create our labels and replace 1 with 2 then replace 1 with 3 and save it. And now we’ve got our options, our labels and now everything here is dynamic. Now there’s nothing specifically that’s hard coded in the output or in the queries, it’s all dynamic.
Save that, we’ll upload it and reload this. What we just did here didn’t change anything however, now this is going to say Bananas, Apples and Cherries because the name matches. And as soon as we come over here and change that to Green Apples and save our settings, now it’s Green Apples instead so the label changed and the content changed.
And that brings my presentation to and end. Obviously there are all kinds of things you can do with this system whereby you create child theme options and then manipulate your site based on those options.