Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the breadcrumb-navxt domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/wordpress/wp-includes/functions.php on line 6114
$post_typeの記事数をカウントする関数 – コンピュータ学

rgb-green.net

$post_typeの記事数をカウントする関数

[php]
// $post_typeの記事数をカウントする。
function fnc_count_post_type($post_type,$days) {
global $wpdb,$from;

// $post_typeは必須: category または oshirase_cat
// $daysは3種類: allは全期間 空白はデフォルト 他はdays
if($days==’all’): $from=’0′;
elseif($days==”): $from = date("Y-m-d H:i:s", time() – 86400*90);
else: $from = date("Y-m-d H:i:s", time() – 86400*$days);
endif;

$sql = <<< HERE
SELECT COUNT(*) FROM $wpdb->posts
WHERE post_type = ‘$post_type’
AND post_status = ‘publish’
AND post_date >= ‘$from’
HERE;
$count = $wpdb->get_var($sql);
return $count;
}
[/php]


© 2023

© 2023 Study of Reason, Inc. All rights reserved.