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

Konrad Pilch
Konrad Pilch
2,435 Points

Whats wrong with this code?

Whats wrong with this code? Why isn't it echo out the recipes level?

<li><i class="fa fa-bolt"></i><strong>Level:</strong><?php echo get_field('recipes_level'); ?></li>

2 Answers

Tiffany McAllister
Tiffany McAllister
25,806 Points

Have you tried 'the_field' instead of 'get_field'?

Konrad Pilch
Konrad Pilch
2,435 Points

Its displaying array all the time, but i know it should work , because i pulled an image

<a href="<?php the_permalink(); ?>"><img src="<?php echo get_field('recipes_image'); ?>"></a>

ANd thas working, but it wont work for my description which i svery unusual : p but im also quite a newbie as well

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

If it is returning an array then you need to loop through it. You may have a field that accepts multiple images?

Konrad Pilch
Konrad Pilch
2,435 Points

I think it does go throw the loop? or is there a special on for it? i mean, in the recent project this doenst work.

                    <?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

                        <div class="col-xs-6 col-md-3 new-portfolio">
                            <div class="project-tab">
                                <a href="<?php the_permalink(); ?>"><h4><?php the_title(); ?></h4></a>

                                <a href="<?php the_permalink(); ?>">
                                    <img class="portolio-image" src="assets/img/webpor.jpg">
                                </a>

                                <a href="<?php the_permalink(); ?>">
                                    <?php $value = get_field( "image" ); ?>
                                    <?php  echo $value ?>
                                    <img class="portolio-image-secondary" src="assets/img/webpor.jpg">
                                </a>

                            </div><!-- /project-tab -->
                        </div><!-- /col-xs-6 col-md-3 -->
                    <?php endwhile; endif;?>