PHP code example of joem / saturn

1. Go to this page and download the library: Download joem/saturn 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/ */

    

joem / saturn example snippets


// Provide arguments.
$args = array(
    'slug'      => 'interview',
    'singular'  => 'Interview',
    'plural'    => 'Interviews',
    'namespace' => 'twentytwenty',
);

// Register the post type.
$saturn = new Saturn($args);

// Run a query, returning 10 posts.
$posts = $saturn->query()->limit( 10 )->runQuery();

// Provide arguments.
$args = array(
    'slug'      => 'interview',
    'singular'  => 'Interview',
    'plural'    => 'Interviews',
    'namespace' => 'twentytwenty',
);

// Register the post type.
$saturn = new Saturn($args);

$saturn->query()
    ->meta( ['name' => 'joe'] )
    ->runQuery();

$saturn->query()
    ->meta([
        ['name' => 'joe'],
        ['age' => 43]])
    ->runQuery();

$saturn->query()
    ->meta([
        ['name' => 'joe'],
        ['age' => 43]],
        ['relation' => 'AND'])
    ->runQuery();

$saturn->query()
    ->tax([
        'taxonomy' => 'people',
        'field'    => 'slug',
        'terms'    => 'bob',
    ])
    ->runQuery();