function all_view global $wpdb; $count = 0; $views=$wpdb-get_resultsSELECT FROM $wpdb-postmeta WHERE meta_key=views; foreach$views as $key=$value $meta_value=$value-meta_value
This function retrieves the total number of views for all posts in the WordPress database. It uses the global $wpdb object to query the wp_postmeta table for all meta_key='views' entries. It then loops through the results and adds up the meta_value field for each entry, treating it as an integer. Finally, it returns the total count of views.
原文地址: https://www.cveoy.top/t/topic/hZ1y 著作权归作者所有。请勿转载和采集!