Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Parent / Child formatting in a list of post of a custom post type.

I am building a long manual for my companies procedures. We have each section (and sub-section) entered as parent and child posts in a custom post type. I have the loop running properly, but I would like to be able to format the children differently from the parents.

I would like it to display as follows:

<h1 class="parent">Parent Title 1</h1>
  <p>section content here...</p>
<h2 class="child"> Child Title 1</h2>
  <p>section content here...</p>
<h2 class="child"> Child Title 2</h2>
  <p>section content here...</p>
<h1 class="parent">Parent Title 2</h1>
  <p>section content here...</p>
<!--and so on-->

I have been reading about nesting loops and extending the Walker Class, but I'm not having any luck. Any ideas or links to articles would be extremely appreciated.

1 Answer

Hi Jonathan,

In this particular case and subject to the complexity of why you need, my best recommendation would be to visit codeable, if you have not already used this service I highly recommend it. As I work on my own I do not have the option to bounce ideas of other and get solutions from more experienced developers. Codeable will give you access to truly expert WordPress developers who will get this running in no time.

It is a paid service but in all my experience its well worth it!

Craig