I thought the content would be printed on this code. However, this code normally outputs title, DATE value, but not content value.
I've tried the_content(); There was no difference. What is the problem?
HERE is my Full code. I'd be grateful if someone could help.
<?php
$peoplePosts = get_posts(
array(
'post_type' => 'notice',
'posts_per_page' => -1
));
if (is_array($peoplePosts)) {
foreach ( $peoplePosts as $peoplePost) {
$get_tit = get_the_title($peoplePost);
$get_cont = get_the_content($peoplePost);
?>
<li class="i-item i-item--active">
<a href="#" class="i-link">
<div class="i-subject"><?php echo $get_tit; ?></div>
<div class="i-date i-date--notice"><?php echo get_the_date('Y-m-d'); ?></div>
</a>
<div class="i-qnaboxs">
<div class="notice_box"><?php echo $get_cont; ?></div>
</div>
</li>
<?php
}
}
?>
regard.
In this part:
foreach ( $peoplePosts as $peoplePost)
Rename the variable to $post
.
Call setup_postdata()
.
Then you can call the_content()
, etc.
So:
foreach ( $peoplePosts as $post) {
setup_postdata( $post );
... your code here
}