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

Flexslider is not showing - Building Custom Wordpress Theme

Hello,

I created my custom wordpress theme following the video tutorials but my flexslider isn't showing up. It shows up ONLY when I exclude this bit of php code (which is the code to add a project after I click Yes on a checkbox):

<?php $display = get_field('display_on_slider'); if( $display[0] == "Yes" ) : ?>

I renamed the checkbox custom field to: "display-on-slider" instead of display on homepage & I renamed the homepage slide image to "slider-image", but I don't see renaming my custom fields as the problem.

Also, I placed my flexslider in the "Portfolio" page (work.php) not in the frontpage.

Here is my website/url

and this is the code on my Portfolio page:

```html

<?php

/* Template Name: Work Page */

get_header(); ?>

<p><a href="<?php echo get_permalink( 80 ); ?>">Home</a> >> <strong>Portfolio</strong></p> <hr>

<div id="featured" class="clearfix flexslider"> <ul class="slides"> <?php $args = array ( 'post_type' => 'work' ); $the_query = new WP_Query( $args ); ?>

    <?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    <?php $display = get_field('display_on_slider'); if( $display[0] == "Yes" ) : ?>
        <li>
            <div class="container">
                <div class="grid_8">
                    <img src="<?php the_field( 'slider_image' ); ?>" alt="<?php the_title(); ?> Project Screenshot">
                </div>
                <div id="featured-info" class="grid_4 omega">
                    <h3><?php the_title(); ?></h3>
                    <p><?php the_field( 'description' ); ?></p>
                    <a class="btn" href="<?php the_permalink(); ?>">View Project</a>
                </div>
            </div>
        </li>
    <?php endif; ?>
    <?php endwhile; endif; ?>
</ul>

</div>

<?php get_template_part( 'content', 'testimonials' ); ?>

<?php get_footer(); ?> ```

1 Answer

Jon W
Jon W
6,185 Points

Hi Adrie. I saw you replied to my post relating to this functionality.

My code pretty much looks the same as yours, except I'm not using Flexslider as I'm just displaying my featured projects in a grid. But the loop, the IF condition are exactly the same. How odd.

You can try putting in a test just to see what the value of the field is. Put this in your loop:

<?php $test = get_field('display_on_slider'); echo $test[0]; ?>

Does it return a "Yes" whenever it goes through the loop?

What does your Advanced Custom Fields page look like for this field? Theres no leading and/or trailing spaces around "Yes" is there?