<?php
/**
* Do not edit this file. Edit the config files found in the config/ dir instead.
* This file is required in the root directory so WordPress can find it.
* WP is hardcoded to look in its own directory or one directory up for wp-config.php.
*/
require_once(dirname(__DIR__) . '/vendor/autoload.php');
require_once(dirname(__DIR__) . '/bootstrap/app.php');
require_once(ABSPATH . 'wp-settings.php');
. В WP обе эти сущности заменяет один PHP-файл шаблона, то есть если нам нужны кастомные запросы, мы пишем их прямо в шаблон, тут же и выводим.пример можно?
if (is_page) echo $blade->make('page', ['name' => 'John Doe']);
if (is_frontpage) echo $blade->make('frontpage', ['name' => 'John Doe']);
Routes::map('/', function() { echo 'is home!' });
Routes::map('my-events/:event', function($params) {
$event_slug = $params['event'];
$event = new ECP_Event($event_slug);
$query = new WPQuery(); //if you want to send a custom query to the page's main loop
Routes::load('single.php', array('event' => $event), $query, 200);
});
Смысл контроллера в этом процессе - получение данных, которые мы должны отправить в шаблон
Routes::map('my-events/:event', function($params) {
$event_slug = $params['event'];
$event = new ECP_Event($event_slug);
$query = new WPQuery(); //if you want to send a custom query to the page's main loop
Routes::load('single.php', array('event' => $event), $query, 200);
});
Routes::map('/:name/page', function($params) {
$query = new WP_Query('post_type=name');
Routes::load('page.php', $params, $query, 200);
});
<?php
namespace App;
use Timber\Timber;
$context = Timber::get_context();
$context['post'] = new \TimberPost();
Timber::render('page.twig', $context);
{% extends "base.twig" %}
{% block content %}
<div class="home-content">
<h1>{{ post.title }}</h1>
<div class="container">
<div class="row">
<h2>Is Page</h2>
</div>
</div>
</div>
{% endblock %}