1. Home
  2. Knowledge Base
  3. Posts Table Pro
  4. Advanced Usage

List posts for current month only

The Posts Table Pro plugin comes with built-in options to list posts based on any combination of day, month, or year. If you'd like an automated way to list WordPress posts for the current month only, then we've provided a code snippet to help with this. For example, perhaps you have a news site and wish to display news articles from the current month on the homepage.

Please note that this is aimed at developers and if you don't know how to use it, then you should ask a developer. If you don't have one, then we've partnered with Codeable to provide customization services for our customers.

We've partnered with Codeable to provide our customers with expert help if required.

Code snippet - list WordPress posts by current month

The following code snippet allows you to specify that you want to list only posts for the current month:

* Allows specifying a value of 'current' for the month attribute in the [posts_table] shortcode.
* The value of 'current' will be converted to the number of the current month.
* @param array $args Shortcode attributes.
* @return array (Maybe) modified shortcode attributes.
function barn2_allow_filtering_ptp_for_current_month( $args ) {
if ( ! empty( $args['month'] ) && 'current' === $args['month'] ) {
$args['month'] = date( 'n' );
return $args;
add_filter( 'shortcode_atts_posts_table', 'barn2_allow_filtering_ptp_for_current_month' );

In practice this looks like: [posts_table month="current"]

Related Articles

If searching the knowledge base hasn't answered your question, please contact support.