1. Go to this page and download the library: Download sanderdekroon/parlant library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Sanderdekroon\Parlant\Posttype as Post;
// Get all articles that are within the category called 'linux',
// limited to 5 results.
Post::type('articles')
->where('category_name', 'linux')
->limit(5)
->get();
// Get articles written by author 42, within the category called 'Meaning of Life'
// and limit it to 14 results.
Post::type('articles')
->where('author', '42')
->where('category_name', 'Meaning of Life')
->orderBy('title', 'ASC')
->limit(14)
->get();
// Get all posts within the posttype 'post' where the post_meta key 'foo' should be equal to 'bar'.
Post::type('post')->whereMeta('foo', '=', 'bar')->get();
// Get all posts within the 'post' posttype where the post_meta key 'secretkey' is not equal to 'hunter2'.
Post::type('post')->whereMeta('secretkey', '!=', 'hunter2')->get();
// Get all posts within the posttype 'jeans' that are within the term called '37' of the 'size' taxonomy.
Post::type('jeans')->whereTerm('size', 'name', 'IN', 37)->get();
// Query all jeans that are either in the term 32, 33, 34 or 35, within the 'size' taxonomy.
Post::type('jeans')
->whereTaxonomy('size', function () {
return $this->relation('OR')->name('32')->name('33')->name('34')->name('35');
})->get();