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

Raja S
PLUS
Raja S
Courses Plus Student 285 Points

Custom Post : the_content() Displays Nothing.

I have created a Custom Post named "question" the custom post will have 4 fields Question , Answer, Answered by and Category . When i try to retrieve the information of the custom post only the title is displayed and the content is not showing up . below is my code snippet

<?php 

                    $args = array('post_type' => 'question','posts_per_page'=>'10');
                    $question = new WP_Query($args);

                    if($question->have_posts()):while ( $question->have_posts() ) : $question->the_post(); ?>

                    <article class="entry-content clearfix">
                    <?php if ( ! $featured_image ) : ?>
                        <h1 class="main-title"><a href="<?php the_permalink();?>"><?php the_title(); ?></a></h1>
                        <?php the_content();?>
                    <?php  endif; ?>



<?php endwhile; endif; wp_rest_postdata();?>

Hi Raja,

This should work, Are sure that you have your content within your main WordPress content editor?

http://awesomescreenshot.com/0653vo9c70

Raja S
Raja S
Courses Plus Student 285 Points

Oh !. i have custom fields as well . messed up . using get_post_meta () solved my problem .

Thank you Muhammad Mohsen Jazakallahu Khair.

Your welcome :)