سلام خدمت استاد گرامی
function prefix_get_post_count( $post_status = 'publish' ) {
global $wpdb;
$cache_key = 'prefix_post_count_'. $post_status;
$_posts = wp_cache_get( $cache_key );
if ( false === $_posts ) {
----->در همه صورت وارد این شرط میشود
$_posts = $wpdb->get_var(
$wpdb->prepare(
"SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = %s",
$post_status
));
wp_cache_set( $cache_key, $_posts,'',50);
}
return $_posts;
}
من این کد اجرا میکنم ولی همیشه وارد شرط میشود دلیلش چیست؟
واین نشان میدهد کش ایجاد نمیشود دلیلش چیست ؟
من به صورت زیر استفاده میکنم ایا درست است؟
باید چکار کنم؟
;()echo prefix_get_post_count
پارامترهای
,$group $found, $force
wp_cache_get در تابع
دقیقا چیست؟ وچه موقع فراخوانی میشوند؟
با تشکر از لطف شما