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

Aj Noguerra
PLUS
Aj Noguerra
Courses Plus Student 5,042 Points

the_content() function is not working for me when I query a custom post type.

the_content() is not working for me when I try to query it from the custom post type I have made. I am applying this lesson in a personal project. The code goes like this:

           <?php
                            $args = array ( 
                                'post_type'  =>  'overview' 
                            );
                            $query = new WP_Query( $args );   
                        ?>

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

                            <?php the_title(); ?>
                            <?php the_content(); ?>  

                        <?php endwhile; endif; wp_reset_postdata(); ?>
Aj Noguerra
Aj Noguerra
Courses Plus Student 5,042 Points

Finally got the answer, it should have been the_field() function and reference to the field of the custom post I'm querying.