I’m using Sober\Controller class, and I want to show some random testimonials on my homepage. they are a custom post type simple custom post type. it supports title, editor and thumbnail
<?php
namespace App;
use Sober\Controller\Controller;
use WP_Query;
class FrontPage extends Controller {
public function random_testimonials() {
$args = array(
'post_type' => 'testimonios',
'orderby' => 'rand',
'posts_per_page' => 3,
);
$the_query = new WP_Query( $args );
return $the_query;
}
}
my problem is not having a clue on how to get those values on the template, tried several things… this is what i think its the closest thing to make the foreach to work, but the variable i’m trying to return is wrong
@if($random_testimonials)
<section class="testimonials">
@foreach($random_testimonials as $testimonial)
{{ $testimonial['post_title'] }}
@endforeach
</section>
@endif
this returns:
Notice: Undefined index: post_title in cache/compiled/ec1ff1ab1f0ae04c6d6f8ab597a68a8965a06a47.php on line 40
nothing seems to work… starting to freak out…