カスタム投稿に専用の通し番号を付与する
functions.phpに以下を追加
function get_post_number( $post_type = 'post', $op = '<=' ) {
global $wpdb, $post;
$post_type = is_array($post_type) ? implode("','", $post_type) : $post_type;
$number = $wpdb->get_var("
SELECT COUNT( * )
FROM $wpdb->posts
WHERE post_date {$op} '{$post->post_date}'
AND post_status = 'publish'
AND post_type = ('{$post_type}')
");
return $number;
}
テンプレートに以下を貼り付ける。
<?php echo get_post_number( $post->post_type ); ?>