Taco

WordPress custom post types that feel like CRUD models


OOP Models

Do you like Laravel’s Eloquent, RedBeanPHP, or Doctrine — but you work in WordPress?

With Taco, WordPress custom post types look and feel like models.

Modern Development

Import Taco via Composer or download a zip. Taco is PSR-4 autoloader compliant.

Taco also runs against lots of PHPUnit tests to ensure everything’s working properly.

Scaffolding

Taco makes quick work of developing WordPress custom post types and custom terms.

You, the developer, get to build your models using code. And Taco automatically creates the WordPress admin interface for managing the content.

Getting Started

Step 1

Load via Composer

Taco is easiest to load via Composer. Just add the Taco entry to your composer.json file, then include the Composer autoloader in your wp-config.php and initialize Taco in functions.php.

You should have the composer.json file one directory above your WordPress directory.

composer.json

{
  "require": {
    "tacowordpress/tacowordpress": "dev-master"
  }
}

wordpress/wp-config.php

// Composer autoloader
// Add to the top of wp-config.php
require_once realpath(__DIR__.'/../vendor/autoload.php');

wordpress/wp-content/your-theme/functions.php

// Initialize Taco
\Taco\Loader::init();

Step 2

Create your plugin

Each custom post type created with Taco should be it’s own plugin.

After activating your plugin in the WordPress admin interface, Taco will automatically register your post type and make it part of your admin interface.

Use the WordPress admin interface to add a test record for person with your first and last name.

wordpress/wp-content/plugins/taco_person/taco_person.php

<?php
/**
 * Plugin Name: taco_person
 */
class Person extends \Taco\Post
{
  public function getFields()
  {
    return array(
      'first_name'=>array('type'=>'text'),
      'last_name'=>array('type'=>'text'),
    );
  }
}

Step 3

Build your template

WordPress automatically pulls a Post object into your templates, which you can pass into Taco, providing you access to all of the metadata stored by Taco.

wordpress/wp-content/themes/your-theme/single-person.php

<?php
$person = Person::find($post->ID);
echo sprintf(
  'My name is %s %s',
  $person->first_name,
  $person->last_name
);

Ready to learn more?

Read the Docs