PHP code example of barnythorpe / wp-fluent-queries

1. Go to this page and download the library: Download barnythorpe/wp-fluent-queries 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/ */

    

barnythorpe / wp-fluent-queries example snippets


$builder = new PostQueryBuilder();
$builder
    ->postType('custom_post_type')
    ->postsPerPage(12)
    ->fields('ids');

$query = Query::post()
    ->postType('custom_post_type')
    ->postsPerPage(12)
    ->fields('ids');

$wp_query = Query::post()
    ->postType('custom_post_type')
    ->taxQuery(QueryGroups::tax(
        QueryConditions::tax()->taxonomy('example_tax')->terms([1, 2, 3])->field('term_id'),
        QueryConditions::tax()->taxonomy('another_tax')->terms([4, 5, 6])->field('term_id'),
    ))
    ->metaQuery(QueryGroups::meta(
        QueryConditions::meta()->compare('=')->type('CHAR')->key('foo')->value('bar'),
        QueryConditions::meta()->compare('!=')->type('CHAR')->key('baz')->value('qux'),
    ));