src/Eccube/Controller/TopController.php line 25

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.ec-cube.co.jp/
  8.  *
  9.  * For the full copyright and license information, please view the LICENSE
  10.  * file that was distributed with this source code.
  11.  */
  12. namespace Eccube\Controller;
  13. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  14. use Symfony\Component\Routing\Annotation\Route;
  15. class TopController extends AbstractController
  16. {
  17.     /**
  18.      * @Route("/", name="homepage", methods={"GET"})
  19.      * @Template("index.twig")
  20.      */
  21.     public function index()
  22.     {
  23.         require_once('../../wpsite/wp-load.php');
  24.         $args = array(
  25.             'post_status' => 'any',
  26.             'post_type' => 'aws-plan',
  27.             'orderby' => 'date',
  28.             'order' => 'DESC',
  29.             'numberposts' => '3',
  30.         );
  31.         $p_posts get_posts$args );
  32.         
  33.         $array=[];
  34.         foreach($p_posts as $post) { 
  35.             $array[] = array(
  36.                 "id" => $post->ID,
  37.                 "list_img" => get_field('list_img',$post->ID)['url'],
  38.                 "title" => get_field('title_en',$post->ID),
  39.                 "list_status" => get_field('list_status_en',$post->ID),
  40.                 "list_text" => get_field('list_text_en',$post->ID),
  41.             );
  42.         }
  43.         return [
  44.             'WpPosts' => $array,
  45.         ];
  46.     }
  47. }