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
- Set post date before 1970
- How to Add Custom Taxonomy To Woocommerce Plugin
- Custom taxonomy not showing up when adding a new custom post type
- query multiple taxonomies
- wp_set_object_terms() is not replacing term, but creating a new one
- Custom Post Type Permalink For Parent/Child, 404 Page Not Found Error
- Create an archive page for custom taxonomies
- Rewrite permalinks for custom posttype and custom taxonomy
- How to check if last uri segment is a custom post type or taxonomy term?
- Categories under custom post types doesn’t show properly
- List all posts in Custom Post Type but group dynamically by Custom Taxonomies
- Custom Post Types, Custom Taxonomies and Permalinks ?
- get a list of posts from Custom Taxonomy
- Trying to manage templates on a blog with lots of custom taxonomies
- Display Custom Category (taxonomy) Name in Custom Post Type
- Separate Posts and Custom Post Type in Custom Taxonomy archive template
- Query to change custom post type with specific category
- Order WordPress Custom Taxonomy Pages & Pagination Not Working
- Custom post type and taxonomy permalinks – Structure
- Best action hook to create custom post and assign taxonomy terms to it on plugin activation?
- Custom Post Type and Custom Taxonomy Permalinks
- Custom Post Types relationships
- How many Custom Post Types to register?
- How can i skip same post from taxonomy term?
- Set menu active state for custom posttype and category, given custom taxonomy term
- How to bulk copy custom fields between custom posts?
- get_attached_media() on author page not working
- Custom post type structure for posts with multiple child posts
- Search / Filter posts on Title/Content OR Tags
- Hide parent categories when clicked, and show it’s childs
- Custom taxonomy and custom post type – wrong permalinks and template
- Get unique superset of taxonomy terms from a list of custom posts in another hierarchical taxonomy
- Auto Complete Search
- permalink /category/post-name with custom post type and taxonomy
- Displaying Custom Taxonomies From Multiple Custom Post Types
- Display and register custom categories for custom post types
- Properly flush rewrite rules on plugin activation
- Adding predefined terms to a taxonomy
- Redirect to archive is single post has a certain term assigned to it?
- Custom query – get_the_terms not work
- Displaying tags associated with posts in Custom Post Type
- Custom taxonomy page returns 404
- portfolio custom type tags support
- Custom taxonomies to define versions of a product
- How to select a template for a custom post type?
- Targeting custom post type via functions.php doesn’t work
- How to get all posts related to particular category name on button click?
- Urls in Custom Post Type work for Terms but not for its Taxonomies
- Display custom posts for each category from its custom taxonomy
- Get custom category ID of current custom post within the loop
- Add filter to Admin list for all custom post types by their custom taxonomies
- Single.php for Custom Post Type > Taxonomy > Term
- Displaying custom taxonomy menu in custom post type archive
- Custom post types templates
- prevent sub categories to show up
- Custom post type category link redirecting to 404 page
- Archive page URL for custom taxonomy and post type
- Custom Post Type Archive Page showing as 404
- Custom taxonomy terms hierarchical navigation
- Is it possible to add the Gutenberg block editor to a custom taxonomy?
- What is the best way to structure posts for the same event happening in different years?
- Create custom post type categories
- Dynamically Adding Posts of Post Type to A List
- Multiple Custom Post Type in Taxonomy Archive Causing White Screen
- Adding a Section for Visitors
- Why is my loop not populating the page with my custom taxonomy terms from my custom post type?
- Show parent category and subcategory once in while loop
- How to get post type archive category title
- Remove CPT Slug with 2 taxonomies and 1 post meta
- Associate custom categories to different user IDs
- How to create default taxonomy term for a custom post type? [duplicate]
- archive-{custom_post_type}.php not getting recognized wordpress
- How to retrieve the permalink for a specific (custom) term?
- Values inside a custom field to determine which category posts to display
- Taxonomy and Rewrite Structure
- Pagination for a Custom Taxonomy
- Trying to create hierarchy between 3-4 custom post types
- title tag for custom post type remove taxonomy name from title tag
- Create a page selector using taxonomies
- Only One Post of Custom Post Type Appearing on Template Page
- Code to show related posts (custom post type and custom taxonomy/category) is messing with other code
- register_term_meta not working
- Filtering custom post types using category taxonomy
- How to use wp_set_object_terms depending on page ID?
- Permalinks for Custom Post Types and Taxonomies