Fetch year-wise month list if have post in a particular month in WordPress

Hey Namaste 🙏,

In a one of the recent project, We have a requirement like need to display year-wise months at the right side of the page and on click any month have to display a list of the blog post of that month using ajax and have to disable month if there no any posts.

Check below screenshot for the better understanding.

Fetch Year Wise Month

For this, We used MySQL query, foreach and array. Please check below code.

If have a blog post in the month then values will set true.

Below is array output, you can use it anyplace as per your need.

author-image

Yuvraj Khavad

Co-Founder, Programmer

I’m Yuvraj Khavad, I work at Z Index Solutions where I am the Co-founder!. I’m also like to read books and draw a painting. I have more than 5 years of experience in web development and web design.

Similar Posts

Trello Tips & Tricks
11/07/2020
Trello Tips & Tricks

What is Trello? Trello is a web-based project & task management tool. Using trello we can do collaborative work with a team member and clients. In another word, trello is […]

Read more
Most useful WordPress Functions
16/09/2020
Most useful WordPress Functions

Hello Namaste 🙏, In this blog post, we will learn the most useful WordPress functions, those functions are very important for custom theme development. About WordPress WordPress is one of […]

Read more