add_action('publish_post', 'dahuzi_update_post_views', 10, 2); function dahuzi_update_post_views( $post_id ) { $rand_views = rand(100, 999); // Randomly obtain a value between 100-999, and change other values if necessary. update_post_meta($post_id, 'views', $rand_views); // Generally, the view field is views. If not, you can change it yourself. }
Official WeChat official account of new theme