you can do that with WordPress functions like that :
$post_type = "tesekkur";
$timestamp_start = strtotime("first day of next month -1 year midnight");
$start = date("Y-m-d H:i:s", $timestamp_start);
$posts = get_posts([
"nopaging" => TRUE,
"post_type" => $post_type,
"date_query" => [
"after" => $start,
],
]);
// sort by month
$tab = [];
foreach ($posts as $post) {
$month = mysql2date("F", $post->post_date);
if (!isset($tab[$month])) {
$tab[$month] = 0;
}
$tab[$month]++;
}
// display
$timestamp = $timestamp_start;
$now = time();
while ($timestamp < $now) {
$month = date_i18n("F", $timestamp);
$count = $tab[$month] ?? 0; // need PHP 7
echo "$month : $count<br/>";
// next month
$timestamp = strtotime("+1 month", $timestamp);
}
Related Posts:
- get_queried_object error How to show post count by month in the taxonomy page
- Post count by month of taxonmy term
- get_queried_object not work in taxonomy page
- Custom Post Type Category List & Post Count
- Taxonomy list. Order by a specific custom post type count
- Count posts with specific term_meta
- Query/list all terms and their custom post count
- WP_Query most viewed posts, in multiple Post Types, last 30 days, excluding a specific taxonomy term
- how to count the current posts terms
- How to count other posts not having specific taxonomy terms?
- Display post count for a specific month
- display post count in archive page that have relation with another taxonomy term
- How to show custom post count in archive page
- How to save an integer as taxonomy term?
- Complex Custom Loop with Includes
- Hide load more button if no more post in selected category
- order taxonomy alphabetical
- What’s the most efficient way to get two queries based on an if statement?
- Facing some Issues on Two Parts Custom Post Type Taxonomy Names
- Adding Custom Taxonomy Along-with Post Name in Post Type Permalink
- I want to display my custom post type arranged by taxonomy
- I want to create an archive and single page for a custom taxonomy for a custom post type
- Customize url from the_terms
- Pretty permalink structure with multiple (AND OR) taxonomies
- Columns depending on posts count
- Custom post types not displaying per category
- Taxonomy’s title
- Display all posts from single taxonomy term
- Display a Custom Post Type within another with hierarchically slug
- Problems with the WP_Query query for a Custom post type
- Want to display my custom date archive to date.php but dont know how
- Connect 8 Taxonomies to One (Main) taxonomy. How to?
- I want fetch custom post with taxonomy id
- Filter a custom taxonomy from displaying a button all other taxonomies can show
- Front page url permalink
- Filter Term By Parent Term – Custom Post Type
- Filter By Term Not Working – Custom Post Type
- How to show post which has the specific taxonomy terms?
- Custom taxonomy term links out of order
- Displaying WordPress posts from post and custom post type in custom taxonomy
- Custom post type category archive URL redirects to home page
- Associate custom CPT with another CPT’s taxonomy and rewrite permalinks
- Custom post type taxonomy template and URL confusion
- Display all Custom taxonomy terms and their relevant custom posts
- Custom Post Hierarchy and users
- Unexpected behavior from custom taxonomies
- Breadcrumb that shows multiple custom taxonomies
- What am I doing wrong with my taxonomy?
- Help with Multi Level Category Archive Page
- Looping through custom taxonomy in one template
- WordPress query posts by custom post type not workng
- How to hook save-post function to use taxonomy term in post-slug?
- Custom post type and taxonomies structure
- Change the url of a custom post type to include taxonomy
- Form to custom post type and custom taxonomy
- WordPress get all post with like in terms [duplicate]
- Displaying custom posts in categories
- Get posts of an specific term of a custom taxonomy
- I have a custom taxonomy assigned to two post types. How do I create URLs for different term archives for each post type?
- Best approach to allow front-end display of posts’ reviewers?
- Query pulling all taxonomies, not one I am specifying
- Custom post type archive page not showing on archive-posttype.php
- CPT url rewriting : regular posts return 404 error
- Post Custom & Taxonomy 404 error
- Show custom taxonomy not in submenu
- WordPress add taxonomies/terms list as a menu in archive page
- conditional based upon the count of current user’s published custom posts
- Custom Post Type rewrite url to /category/pagetitle [duplicate]
- Getting a 404 on single custom post type page when using rewrite on a custom taxonomy
- Creating adminable dynamic filtering on custom post type
- Should I make a taxonomy to organize data like this?
- Custom Post Type tag taxonomy “Page Not Found”
- Custom Post Type Taxonomy – Permalinks generating, but posts not found
- Remove custom post type slug but keep related category taxonomy permalink
- Custom Taxonomy is disabled on Edit page
- Need some suggestion/help with custom post types project
- page not found for example.com/custom-post-name
- Display posts grouped by post type in taxonomy.php
- Advice on Categorization for a Custom Post Type
- Custom post type based on existing one
- Pods pagination erases my sub menu
- Override “Parent” input for custom taxonomy
- Best way to use Category & Custom Fields?
- Decrement term in for each
- How to have permalink structure based on taxonomy terms
- Create 2-layered dropdown menus for custom taxonomy and custom post type
- Pre_get_posts comparison with custom field doesn’t work
- Problem with type plugin and custom taxonomies
- Checking Taxonomy Terms for a Custom Post Type With get_the_terms Not Working
- Display year value before a set of posts
- Display Taxonomy Term for CPT on single-CPT.php
- Ordering Posts List By Taxonomy Terms?
- Force WordPress to only match URL in category
- CPT Efficient way to display posts from different categories with custom query
- Custom Taxonomies in body class with parent slug
- Custom Post Type categories at edit post not hierarchical
- Multiple archives for cpt, taxonomies, terms
- YearWise Categorywise Post
- How to Fix WordPress 500 Internal server error due to custom post type
- Custom post type with custom taxonomy permalinks