PHP code example of 10quality / wp-query-builder

1. Go to this page and download the library: Download 10quality/wp-query-builder 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/ */

    

10quality / wp-query-builder example snippets


$books = wp_query_builder()
    ->select( 'ID' )
    ->select( 'post_name AS name' )
    ->from( 'posts' )
    ->where( ['post_type' => 'book'] )
    ->get();

foreach ( $books as $book ) {
    echo $book->ID;
    echo $book->name;
}