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
関数 – コンピュータ学

rgb-green.net

関数

「 関数」のページ記事

$post_typeの記事を抽出する関数

投稿者:admin
タグ: $post_type 抽出
カテゴリ: function

[php]
// $post_typeの記事を抽出する。
function fnc_read_post_type($post_type,$days) {
global $wpdb, $from, $offset, $per_page;

// $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;

$obj = new stdClass;
$sql = <<< HERE
SELECT *
FROM $wpdb->posts
WHERE post_type = ‘$post_type’
AND post_status = ‘publish’
AND post_date >= ‘$from’
ORDER BY post_date DESC
LIMIT $offset, $per_page
HERE;
$obj = $wpdb->get_results($sql);
return $obj;
}
[/php]

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

投稿者:admin
タグ: 抽出
カテゴリ: function

[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.