PHP code example of mehedimi / wp-query-builder-ext
1. Go to this page and download the library: Download mehedimi/wp-query-builder-ext 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/ */
mehedimi / wp-query-builder-ext example snippets
// Retrieve all posts with associative taxonomies.
DB::table('posts')
->withRelation(new WithTaxonomy('taxonomies'))
->get()
// Retrieve all posts with associative taxonomies group by with its type.
DB::table('posts')
->withRelation(new WithTaxonomy('taxonomies'), function(WithTaxonomy $taxonomy){
$taxonomy->groupByTaxonomy()
})
->get();
// This will fetch only category type of taxonomy.
DB::table('posts')
->withRelation(new WithTaxonomy('categories'), function(WithTaxonomy $taxonomy){
$taxonomy->taxonomy('category');
})->get();
DB::plugin(new JoinPostWithMeta())->select('posts.*')->where('meta_key', 'some meta key name')->get()
// For joining right join `postmeta` with `posts` table
DB::plugin(new JoinPostWithMeta('right'))->select('posts.*')->where('meta_key', 'some meta key name')->get()
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.