Skip to content

Instantly share code, notes, and snippets.

@EITANINOMIYA
Last active December 15, 2016 05:58
Show Gist options
  • Save EITANINOMIYA/1c40318bc0311439fe700f0d827e96ec to your computer and use it in GitHub Desktop.
Save EITANINOMIYA/1c40318bc0311439fe700f0d827e96ec to your computer and use it in GitHub Desktop.
【wordpress】バッチの雛形
/*#################################################
# バッチの雛形
# php wp-content/shell/xxxxxxxxxx.php
#################################################*/
<?php
// wp-load.phpファイルがある階層を指定
$wp_root = __DIR__ . '/../../../../';
if (file_exists($wp_root.'/wp-load.php')) {
require_once($wp_root.'/wp-load.php');
} else {
die('error');
}
// wp-load.phpさえ読み込み出来れば、functions.phpに定義してある関数等も自由に使える
$options = [
'post_type' => 'post'
];
$results = new WP_Query($options);
var_dump(count($results->posts));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment