Last active
December 15, 2016 05:58
-
-
Save EITANINOMIYA/1c40318bc0311439fe700f0d827e96ec to your computer and use it in GitHub Desktop.
【wordpress】バッチの雛形
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*################################################# | |
# バッチの雛形 | |
# 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