All you need to do is modify the SQL query. Using the code you linked as a base:
$numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status="publish" AND year(post_date) = 2010");
if (0 < $numposts) $numposts = number_format($numposts);
The ‘AND’ I added basically gives you all the posts of 2010. Change the year accordingly
Related Posts:
- Simple way to calculate median with MySQL
- Blog statistics
- Possibility to Display Most used Words?
- Counting number of visits to my website
- Looking for references to WordPress Popularity Statistics
- Check which user saw which page
- Looking for simple and lightweight plugin for post reading stats
- Remove views in single post [closed]
- How to move my stats to a self-hosted website?
- Still using WP Stats without Jetpack
- Delete old JetPack Site Stats? encrypted_search_terms in top search terms [closed]
- Plugin to show how far users are reading? [closed]
- SQL WITH clause example [duplicate]
- The wait operation timed out. ASP
- MySQL query String contains
- mysql Foreign key constraint is incorrectly formed error
- SQL Server : Arithmetic overflow error converting expression to data type int
- How to calculate percentage with a SQL statement
- Can a foreign key be NULL and/or duplicate?
- When to use SELECT … FOR UPDATE?
- How do composite indexes work?
- Sql query – getting rid of hard-coded values
- ORA-00918: column ambiguously defined in SELECT *
- How To Run A Github Repository?
- SQL Server reports ‘Invalid column name’, but the column is present and the query works through management studio
- Remote table-Valued Function Calls are not allowed
- Exclude a column using SELECT * [except columnA] FROM tableA?
- Why is SQL server throwing this error: Cannot insert the value NULL into column ‘id’?
- pg_ctl: no database directory specified and environment variable PGDATA unset
- SQL – WHERE (X, Y) IN (A, B)
- Difference between INNER JOIN and LEFT SEMI JOIN
- SQL conditional SELECT
- How can I search (case-insensitive) in a column using LIKE wildcard?
- ‘CREATE PROCEDURE’ must be the only statement in the batch (Erro)
- SQL – IF EXISTS UPDATE ELSE INSERT INTO
- Solutions for INSERT OR UPDATE on SQL Server
- CASE IN statement with multiple values
- List of special characters for SQL LIKE clause
- Use wpdb->prepare for `order by` column name
- Whats the difference between post_limits and pre_get_posts?
- Export WordPress Posts and Meta Information in CSV format
- wpdb->prepare function remove single quote for %s in SQL statment
- Track advertisement earnings per blog post and page in wordpress?
- Import old SQL dump into new WordPress version
- Is there a (better) way to access $wpdb results?
- Get the timout value of a saved transient?
- get posts and postmetas in assoc array
- Update user_login, user_nicename, and display_name
- Change sticky status of posts from phpMyAdmin
- Modify the structure of data returned by $wpdb
- WordPress and MySQL: how to transfer Meta_key and Meta_Value from one post_id to another
- Do I need to deal with WordPress SQL Injection
- Detect session/cookie variable in wordpress to prevent access to documents
- Woocommerce – Changing the order of the upsell products [closed]
- SQL Database, repeated tables?
- Create table from array with prepare
- Risk of sql injection for custom search form
- Include data from custom table in WP_Query
- How change user type from contributor to author
- Does deleting a Plugin via the WordPress admin ‘completely’ remove the code?
- Increment integer field in database when WHERE needs to be dynamic [closed]
- Update table wp_term_taxonomy.count after INSERT INTO via SQL
- Make a SQL query with wpdb in WordPress
- Add estimated value for a post according to the number of words
- Custom $wpdb returns unexpected time based results
- Getting rid of unwanted nonSQL syntax characters when debugging a query
- How to Assign / Move all Deleted post to a category
- Make a loop to return x number of posts, but only if they have content or excerpt
- How to delete a particular row in a database table
- Clean up very big and very dirty database
- What is the point of get_comment_count() if you cannot limit by a comment type?
- How to obtain “wp_rest” nonce for WP Statistics plugin manually?
- custom tables in wordpress Database? (can i just create them with sql?)
- SQL query injection with fifu image
- Change pure SQL database query to WordPress post query?
- Bulk delete WordPress Post and all metadata, etc using SQL query
- WP Optimization: Overwriting options to autoload=yes for often used options?
- WordPress SQL Prepare
- Accidently changed the GUID
- Translating WP query into to SQL query
- Help posting values to DB on submit using $wpdb->query
- Query to show average # of months all accounts with specific role have been active
- How to create index (sql) to a meta_key?
- Bulk update set of URLs via SQL
- Changing an array of IDs in the usermeta table to fit different format
- How to search CPTs in draft using get_page_by_title()
- How to refactor DB queries for better TTFB in WordPress?
- Getting error in sql query
- Display MySQL as part of a Page
- $wpdb not working
- Get all posts from db between 2 specified months
- SQL query to remove first image in all posts
- Removing links from posts in WordPress
- Query sql for truncate post_content in wp_posts table
- How to export database correctly for local to online
- finding out the top 5 source ( source is a custom taxonomy ), in a given category
- Query WordPress Database and Post HTML Table
- SQL get last entry of a specific gravity form
- Deleting the MySQL database
- Batch Scanning and Deleting Empty WordPress Posts