<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bechwebbkonsult / wordpress-template-models example snippets
class HomeTemplateModel extends TemplateModel
{
public $terms = [];
public function __construct()
{
foreach (get_terms(['taxonomy' => 'bf_calendar', 'hide_empty' => false]) as $term) {
$term->url = get_term_link($term->term_id);
$this->terms[] = $term;
}
}
}
use Bechwebb\TemplateModels\TemplateModelProvider;
$templateModelProvider = new TemplateModelProvider;
$templateModelProvider->register('/home.php', \App\TemplateModels\HomeTemplateModel::class);
foreach ($terms as $term) :
use Bechwebb\TemplateModels\TemplateModel;
class CalendarSidebarTemplateModel extends TemplateModel
{
public $title = '';
public $posts = [];
public function __construct($title, $post_type)
{
$this->title = $title;
foreach (get_posts((['post_type' => '$post_type']) as $post) {
$post->url = get_post_permalink($post->ID);
$this->posts[] = post;
}
}
}