Skip to content

Instantly share code, notes, and snippets.

View orangerdev's full-sized avatar
🏠
busy mending broken

Ridwan Arifandi orangerdev

🏠
busy mending broken
View GitHub Profile
@orangerdev
orangerdev / ridwan-wp-query.php
Last active January 4, 2018 05:33
Remodel WP_Query with chunked posts
<?php
namespace Ridwan;
class WP_Query
{
protected static $chunk = 10;
protected static $args = [];
protected static $posts = [];
protected static $respond = [];
@orangerdev
orangerdev / chunk-wp-query.php
Created October 13, 2017 07:14
Chunk WP_Query to get all posts
<?php
$found_posts = true; // Set as true
$offset = 0; // Set start post
$posts_per_page = 20; // Chunk for each 20 posts
while($found_posts) :
$query = new WP_Query([
'posts_per_page' => $posts_per_page,
'offset' => $offset
]);
@orangerdev
orangerdev / task-3-wp-cli.php
Last active October 10, 2017 07:32
TASK 3 - WPI CLI
<?php
namespace WP;
class CLI
{
/**
* Construction
*/
public function __construct()
@orangerdev
orangerdev / task-2-wp-endpoint.php
Last active October 10, 2017 07:29
TASK 2 - WP Endpoint
<?php
namespace WP_Endpoint;
class Notifier
{
protected $valid = true;
protected $messages = [];
public $email = '';
@orangerdev
orangerdev / task-1-companies-order.php
Last active October 10, 2017 07:23
TASK 1 - Ordering companies by sponsored and ranking
$args = [
'post_type' => 'company',
'posts_per_page' => 100,
'meta_query' => [
'relation' => 'AND',
[
'key' => 'sponsored',
'value' => [0,1]
'compare' => 'IN'
],