I am trying to display 5 posts in widget. All I do is:
$post_arguments = array(
'posts_per_page' => 5,
'post_status' => 'publish',
'post_type' => 'industry_news'
);
$posts_array = get_posts( $post_arguments );
So far so good, in my html i have the following foreach:
foreach ($posts_array as $single_post) {
?>
<ul class="tabs-content">
<li class="tab-active">
<div class="article"><a href="#"><img width="260" height="140" class="wp-post-image" alt=""></a>
<h3 class="title">
<a href="http://example.com/example"
title=""><?php $single_post->post_title ?></a>
</h3>
<p><?php $single_post->post_content ?></p>
</div>
</li>
</ul>
</div>
<?php
}
The problem is that the post_content
and post_title
are not displaying in the page. Why?
Please use 'echo'
foreach ($posts_array as $single_post) {
?>
<ul class="tabs-content">
<li class="tab-active">
<div class="article"><a href="#"><img width="260" height="140" class="wp-post-image" alt=""></a>
<h3 class="title">
<a href="http://staging.smartmeetings.com/destinations/98313/south-carolina-food-guide"
title=""><?php echo $single_post->post_title ?></a>
</h3>
<p><?php echo $single_post->post_content ?></p>
</div>
</li>
</ul>
</div>
<?php
}