Welcome to the Treehouse Community
Looking to learn something new?
Display on Home Page Slider checkbox
I just finished the Extending WordPress Template Functionality of the Wordpress videos and while Zac made a point earlier to add a check box for Display on homepage Slider in the custom fields of projects he never showed us how to implement this when finally did implement the slider.
Was this an oversight, otherwise what references can I read up on to know how to make this myself?
Also, on a related note was there ever a link to the WordPress project files for us to reference?
I just asked this question before realizing it was already asked a month ago. Did you ever find any solution?
Jonathan Davies2,162 Points
Yeah this also work perfectly, also note make sure to check if the name of 'display_on_homepage' is the same as what you have name in your ACF.
Thanks Daniel Great fix!
I actually needed the checkbox option instead of T/F for a project I was working on, so I went over to the ACF support page and there was a piece of code there that worked perfectly for me. I went ahead and plugged in the variables that Zac Gordon used in his videos. Hope this helps!!
<?php $args = array( 'post_type' => 'work', 'meta_query' => array( array( 'key' => 'display_on_homepage', // name of custom field 'value' => '"Yes"', // matches exactly "Yes", not just yes. This prevents a match for "acquired" 'compare' => 'LIKE', ) ), 'posts_per_page' => 3, 'order' => 'DESC' ); $the_query = new WP_Query( $args ); ?>