Search
 
SCRIPT & CODE EXAMPLE
 

PHP

wp_cache_get

function prefix_get_post_count( $post_status = 'publish' ) {
    $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 );
    }
  
    return $_posts;
}
Comment

PREVIOUS NEXT
Code Example
Php :: accessing json data in php 
Php :: laravel log reader 
Php :: laravel activity log package 
Php :: wp php get product item attributes name 
Php :: how to include file in laravel blade 
Php :: ini_set php 
Php :: php loop html select option 
Php :: associate laravel 
Php :: admin-ajax.php 400 (bad request) 
Php :: phpmyadmin 403 forbidden centos 6 
Php :: PHP Fatal error: Uncaught Error: Call to undefined function mcrypt_encrypt() 
Php :: php string interpolation 
Php :: wc php if is product category page 
Php :: rename migration laravel 
Php :: set posts_per_page 
Php :: how make a variable global php 
Php :: doctrine querybuilder select alias 
Php :: null value in php 
Php :: wordpress get product category name by termid 
Php :: Converting timestamp to time ago in PHP 
Php :: php add array to array 
Php :: Sum two numbers in PHP with HTML input form 
Php :: create custom header in wordpress 
Php :: parsing html in php 
Php :: ternaire echo isset php 
Php :: mysqli exception handling 
Php :: php if elseif endif 
Php :: Notice: Array to string conversion php 
Php :: how to redirect to another page in php after submit 
Php :: integrate fontawesome in blade laravel 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =