1. Go to this page and download the library: Download johnbillion/args 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/ */
johnbillion / args example snippets
$query = new WP_Query( [
'post_type' => 'post',
'category' => 'does this accept an ID or a slug?',
'number_of_...errr'
] );
$args = new \Args\WP_Query;
$args->tag = 'amazing';
$args->posts_per_page = 100;
$query = new \WP_Query( $args->toArray() );
$args = new \Args\WP_Query;
// Create a clause
$clause = new \Args\MetaQuery\Clause;
$clause->key = 'my_meta_key';
$clause->value = 'my_meta_value';
// Add the clause
$args->meta_query->clauses[] = $clause;
$query = new \WP_Query( $args->toArray() );
$args = new \Args\WP_Query;
// Create a clause
$clause = new \Args\TaxQuery\Clause;
$clause->taxonomy = 'post_tag';
$clause->terms = [ 'amazing' ];
// Add the clause
$args->tax_query->clauses[] = $clause;
$query = new \WP_Query( $args->toArray() );
$args = new \Args\WP_Query;
// Create a clause
$clause = new \Args\DateQuery\Clause;
$clause->year = 2000;
$clause->compare = '>=';
// Add the clause
$args->date_query->clauses[] = $clause;
$query = new \WP_Query( $args->toArray() );
$args = new \Args\WP_Query;
// Set the meta query from an array
$array = [
[
'key' => 'my_meta_key',
'value' => 'my_meta_value',
]
];
$args->meta_query = $args->meta_query::fromArray( $array );
$query = new \WP_Query( $args->toArray() );
declare( strict_types=1 );
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.