<?php
/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Eccube\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\Routing\Annotation\Route;
require_once 'wp/wp-load.php';
require_once 'wp/wp-includes/class-wp-query.php';
class TopController extends AbstractController
{
/**
* @Route("/", name="homepage", methods={"GET"})
* @Template("index.twig")
*/
public function index()
{
// ----------------- //
// ブログ取得
// ----------------- //
$args = array(
'post_type' => 'blog',
'posts_per_page' => -1,
);
$res = new \WP_Query($args);
$Blogs = [];
if ($res->have_posts()):
while ($res->have_posts()) : $res->the_post();
$dat = [];
$dat['ID'] = get_the_ID();
$dat['post_date'] = get_the_time('Y.m.d');
$dat['post_title'] = get_the_title();
$dat['link'] = '/blog/view/'.$dat['ID'];
//$dat['img_src'] = get_thumb_src(get_post_thumbnail_id(), 'large');
$dat['img_src'] = get_field('cf_blog_banner');
//$banner = get_field('cf_blog_banner');
$Blogs[] = $dat;
endwhile;
wp_reset_postdata();
endif;
return ['Blogs'=>$Blogs];
}
}