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

General Discussion

How to Build a WordPress Theme, featured project

So in the "How to Build a WordPress Theme" on the home page there is a slider to show featured work, it however simply displays all work (one at a time.. or one per slide).

In this tutorial we added a custom field of "display_on_the_homepage", but we never used it. No matter if this check-box is ticked or not projects still show up in the slider. As do their images.

I've looked at the arguments array and I some how need to implement 'the_field('display_on_the_homepage')' => true, or something of the likes but I can't get it to work.


2 Answers

Not too sure of the context, but in order to have a feature like this work, your display code will need to read the filter as well. You need some kind of conditional that is something along the lines of:

    if($item->display_on_the_homepage == true){

That's the logic I would use to create a conditional that filters what is added to the slider, but again, I am not entirely sure if this fits the exact context that you are inquiring about?

(This conditional could also be placed in the actual loop code)

   foreach($something as $something_else){
        if($something_else->display_on_the_homepage == true){
           // Show image on slider
        } else {
            // display_on_the_homepage was false, handle a false value here.

thanks I'll be looking to that mate, bout to shoot you an email with a link btw.