function get_draftcount($var) { $posts = get_draft_posts(); $tmp = array(); foreach ($posts as $index => $v) { $filepath = $v['dirname'] . '/' . $v['basename']; // Extract the date $arr = explode('_', $filepath); // Replaced string $replaced = substr($arr[0], 0, strrpos($arr[0], '/')) . '/'; // Author string $str = explode('/', $replaced); $cat = $str[count($str) - 3]; if (stripos($cat, "{$var}") !== false) { $tmp[] = $v; } } return count($tmp); }
function get_draft($profile, $page, $perpage) { $posts = get_draft_posts(); $tmp = array(); foreach ($posts as $index => $v) { $url = $v['dirname']; $str = explode('/', $url); $author = $str[count($str) - 2]; if ($profile === $author) { $tmp[] = $v; } } if (empty($tmp)) { return; } return $tmp = get_posts($tmp, $page, $perpage); }