Using a query could give you easier customization without having to use SQL directly.
$posts = get_posts( array(
'post_type' => 'post',
'post_status' => 'any',
'numberposts' => -1,
'fields' => 'ids',
));
$total_count = count( $posts );
print_r ( $total_count );
Related Posts:
- C++ – how to find the length of an integer
- How can I make a PHP counter?
- Counting the posts of a loop (WP_Query)?
- Category and children post count
- Hide the post count behind Post Views (Remove All, Published and Trashed) in Custom Post Type
- How to display 2 equal columns of li based on the count of items in wp_nav_menu divided by 2?
- Show weekly posts statistic in WordPress
- Increasing post view count automatically [duplicate]
- Count number of posts by author in a category
- How we count the user draft posts
- What is the best way to count and display the number of posts?
- Get count of terms with a post and another taxonomy term?
- Get Gravity Forms field values and count how many? [closed]
- Counting posts in custom post type by author
- Show ellipsis (…) only if the number of characters exceeds limit defined in substr
- Get total views of all posts by author
- Count post + add number =
- How to do simple addition to increase favorites count of my wordpress posts
- Count posts published in one particular day: the lighter way
- What is the best way to do this? [closed]
- Search Count WordPress Theme
- How to read out the excerpt length (for if-condition)
- $count_posts->draft & published
- CountPost WordPress Custom Taxonomy
- get the count of table rows
- How to calculate posts number? [closed]
- How make animation increase of number
- Having problems getting the number of plays in a WordPress Playlist from an audio file
- How to find length of digits in an integer?
- How to count instances of character in SQL Column
- How to mark every 3rd post
- Taxonomy count per Post type
- Count the number of images uploded on the website
- Total word count for posts by one author
- How to cache a shortcode functions output?
- Count posts or custom post types from last 24 hours (or from today)
- Count singular post views automatically
- taxonomy list display custom post count
- Display the number of published posts for each custom taxonomy term?
- Set font size automatically according to number of words in post
- User Published Post Count
- Custom Post Type Category List & Post Count
- Limit tag word count
- Add character count to custom metabox
- Shortcode with product catgory counter
- Count posts for each year
- How to change post count in wordpress loop?
- How do I count how many top level categories there are?
- How to get the number of child categories a specific parent category has?
- Check if an array of posts has posts from a specific category
- Count total number of post in foreach loop
- Show the author’s count of total amount of posts assign to a custom taxonomy term
- Display posts count in front of the tag, for each tag
- right_now_content_table_end function not working?
- How can I count post views of REST API calls and update them in an ACF field?
- Enumeration Contact form using database table’s numbe of rows [closed]
- Getting the current post number / make posts increment
- User’s total comment count excluding comments on their own posts
- How can I make the loop not count special post formats towards the post count?
- How to use wp_query to post count by search term > group post count by date > convert to json. (ex. result 12-21-2020 – 343)
- There any way to get de percentage of number of post by user and category?
- Get count of custom post tags
- How to update the counter of private pages in the dashboard?
- Word count not accurate – potential bug
- How do I display an image before the first post of the loop when I’m using get_template_part?
- Counting posts with argument without retrieving the posts
- How to add category post count in main navigation menu [closed]
- How to count the number of archives there are
- Add estimated value for a post according to the number of words
- Counter is skipping post when I still want it visible [closed]
- Single.php Category Post Count
- Display count of new members registered today [closed]
- Post loop count is not in order
- How can i count post from my post type taxonomy
- How can i count the post added in relationship field, theme display
- Show the amount of posts in a tag in a specific category has
- I am trying to get cutom post cout by month of current taxonmy term
- Divide post content in three columns
- Having a variable based on $post_count increase when i move to the next page of results
- It doesn’t matter if I have more than one comment. get_comments_number still equal to one?
- Show the number of the post
- Author post count in category
- How can I show how much water got saved on this order (making use of the number of items bought) on a thank-you-page?
- Count how many posts have a specified tag AND category
- Show post count in custom taxonomy page
- Count singular post views automatically
- How to count posts in tags within time limit
- Author.php Page views counter
- Display number of post published every day
- WPDB delivers wrong results from complex queries
- For each 3 posts, show a different post type
- Counting custom post type with wp_count_posts returns an empty object
- How to mark every 3rd post
- Add a minimum word count to Excerpt (and how to force Excerpt as a rule for WyPiekacz)
- Order taxonomy terms by the frequency of use in the last 30 days
- ho can I get the number of the current post instead of the post id?
- Adding Count Post in Page
- Count words for all posts by all authors
- Count images in post then add class if just one
- Word count for all posts of all authors