I tried to reach this site Working laravel 4 and 5 and WordPress together, however there is one more thing I utterly don’t get on my blade page. I would like to post my articles from my blog on my Laravel page, working with “foreach” and standard WordPress syntax. Still I get an error. Here’s my code.
I follow this from the site.
class CreicController extends BaseController {
public function index()
{
$query = new WP_Query(array(
'post_type' => 'posts',
'post_per_page' => 4,
'order' => DESC,
));
$posts = $query->get_posts();
return View::make('layouts.creic')->with('posts', $posts);
}
}
and I would like to use foreach to my blade page then i get lost (i tried to copy and do something in php but no luck).
Here’s my old PHP before Laravel
<!-- Start Articles -->
<?php
$posts = get_posts('numberposts=4&order=desc');
foreach ($posts as $post) : setup_postdata( $post );
?>
<artcile class="col-xs-12 col-sm-12 col-md-6 article-section">
<div class="media">
<div class="media-left">
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail( array(80,80, true) ); ?>
</a>
</div>
<div class="media-body">
<h4 class="media-heading"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
<time datetime="2015-2-23T01:30:08Z" title="February 23, 2015" class="timeago"></time>
</div>
</div>
</artcile>
<?php endforeach; ?>
<!-- End Articles -->