Besides this suggestion, here is a simple SQL
query adapted from the core wp_get_archives
function:
SELECT
YEAR(post_date) AS `year`,
MONTH(post_date) AS `month`,
count(ID) as posts
FROM
wp_posts
WHERE
post_type="post" AND post_status="publish"
GROUP BY
YEAR(post_date), MONTH(post_date)
ORDER BY
post_date DESC
This would provide with a structure like this:
+------+-------+-------+
| year | month | posts |
+------+-------+-------+
| 2015 | 5 | 1 |
| 2015 | 4 | 1 |
+------+-------+-------+
You can use $wpdb->get_results
for this query.
Related Posts:
- How to fix ‘Notice: Undefined index:’ in PHP form action
- How to determine if WP_DEBUG is enabled? [duplicate]
- Pass a PHP variable to another file
- Modify image while uploading
- Using Global Variables Expensive for PHP
- One button to change all settings in theme customizer?
- Add custom image sizes to media uploader
- Export all post from database to JSON only when the database gets updated
- How php content after the first and second paragraph
- Multiple pages on one with different HTML
- How to resolve error “Cookies are blocked due to unexpected output.”?
- Is $hook a global variable in WordPress
- Notice: wpdb::prepare was called incorrectly. The query argument of wpdb::prepare() must have a placeholder
- Convert imploded plain text into links
- Add “last” and “first” to WordPress Comment Pagination Links
- WordPress get pagination on wpdb get_results
- PHP if Condition not working
- How to return a foreach inside a shortcode
- Extend a class of a plugin
- Include a php file from functions.php only to homepage
- How to get the Page Number of the Current Page in Single Post Pagination
- How to restrict page access to logged-in users?
- Handling Body class based on Template
- Is XAMPP faster than running LAMP in WSL on Windows 10? [closed]
- Changing layout with wp_customise
- Get updated query results on page after insert in database
- Mass update excerpt
- Get post id in a function when edit/add a post
- Reconfiguring WordPress site
- Use Icomoon external svg file with
- Is it possible to intercept all ajax requests and get the parameters and the returns?
- get_template_part based upon post’s category
- How to split links generated into an xml sitemap to avoid exceeding 30 sec maximum execution time?
- Hacked WordPress website /Homepage redirect [closed]
- Query if audio attachment AND/OR custom field
- Database query works fine outside WordPress
- Loading index.php contents which located outside blog folder for post single page
- WordPress page content outside WordPress
- Pull Tags But Not as Links
- Define specific category name in PHP
- Can I get an email notification when media is uploaded to the media library?
- How to solve Woocommerce Memory Limit
- Shortcode to find and replace URL
- Function Reference Documenting Template Tags for use in Custom Theme Templates?
- Seo Friendly Filter URLs
- PHP contact form not redirecting [closed]
- Add value to new attribute inside WordPress menu items
- Please show me how to use an if/else statement in combination with wp_enqueue
- Add new post in existing categories using wp_insert_post
- I’m unable to call img path using single quotes in an array?
- Else/If Statement to Display Photo Descriptions
- PHP error with a shortcode: “no suitable wrapper” for file_get_contents
- Correct code to use php in text widget
- How to correctly load a different version of main menu based on the user language in WordPress? Is it a good solution?
- custom header text
- Display additional page templates and a sidebar on plugin activation
- Too many errors on log
- I am trying to edit the homepage of the Shopper. Since published I can not make changes and wanted to see if i can disable in (tpl-page-homepage.php)
- I need to display posts in subcategory beside posts in main category
- Trying to copy linux blog locally with XAMPP – php fatal error
- unsetting actions (edit and trash) of specific posts from that list of all pages or posts based on each posts metabox value
- Add a Metabox checkbox to the Page Edit screen of wp-admin , which only certain roles can see and Makes only certain roles able to Edit said page
- Custom URL for multiple categories hierarchy
- Display Results of SQL Query on WP site
- How to search order using database frontend short code WordPress
- if get_post_meta is empty echo a placeholder or shortcode
- PHP Warning: mysqli_query(): after updating my websites php from 5.6 to 7.2
- Categories does not show Block editor WordPress
- Foreach Loop Of Post Types With Nested If Else If Not Completing Process
- WordPress Slick Slider + Magnific Popup
- Fix common misspellings/errors based on array of replacements
- Search for single post by 2 tags
- Import Instagram post as WordPress post
- How to put a before and after with tags in a wordpress entry?
- How to call a WP Class inside my theme
- spl_autoload_register is slow for WordPress sites
- Contactform7: display results from CURL
- Adding a widget under an ‘Add to Cart’ button through a PHP snippet
- How to update option field in database on clicking the publish button in customizer
- Allow Submit Contact Form Default Text In Text Box
- Add ID to output only for first option
- get_post_thumbnail_id returns a negative number
- Front end/Database connection in WP
- Escaping html for meta description
- How to make 2 similar functions more efficient
- how use php query in AJAX jquery
- Div Missing In Custom Loop Query
- Insert wordpress tags below posts via functions.php
- how to manipulate HTML parameters using PHP conditions
- Add multiple JavaScript files to template header [duplicate]
- Can i show items based on the day with php?
- How can I add page template after post of a post type?
- How to insert a variable into a query parameter?
- How to edit homepage in WordPress?
- Adding Custom JQuery Menu Fresh Slide Out
- How I can give a php page a style from my theme
- Product Search in search.php
- Background Tasks in a WP Cronjob?
- How to execute a shortcode within a custom field?
- using custom pages for myaccount in woocommerce