Provide zblog template_zblog them_wordpress template download and customization

Wordpress gets the total number of articles, categories, tags, etc

Tianxing Studio 2021-12-23 22:24 Wordpress Tutorial one thousand two hundred and ninety-five 0 Comments


In production Wordpress template Will be called when website The total number of articles, the total number of categories, the total number of tags, etc. It would be too much to directly query the database with count. Good thing wordpress Some tags are built in to directly obtain these values. This article collates some commonly used WordPress website total tags.

Total number of articles:

 <? php $count_posts = wp_count_posts();  echo $published_posts =$count_posts->publish;?>

Total pages:

 <? php $count_pages = wp_count_posts('page');  echo $page_posts = $count_pages->publish;  ?>

Total number of categories:

 <? php echo $count_categories = wp_count_terms('category');  ?>

Total number of tags:

 <? php echo $count_tags = wp_count_terms('post_tag');  ?>

Total number of users:

 <? php $users = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users");  echo $users;  ?>

Can't find a tutorial that can solve your problem?

You can try to search or ask questions directly online. We also provide charging technical support. If you need it, you can contact us online.

Online questions Online Service

welcome you Comment: Cancel Reply

 Please fill in the verification code
  • Latest articles
  • Hot article ranking
  • Most Comments
Label aggregation
  • Sign in
  • Registered account Forgot your password?
  • register
  • Already have an account? Direct login Forgot your password?
  • Social account login