I have a custom post type called "papers" and I need to create an array with all the archive links per year that exists. Something like:
array (
[0]=> 'http://www.example.com/2021/?post_type=papers'
[1]=> 'http://www.example.com/2019/?post_type=papers'// cause there's no post in 2020
[2]=> 'http://www.example.com/2017/?post_type=papers'
)
I’ve been told to use get_archives()
but that just gives me a formated list, not an array I can use to feed another function. Or am I doing something wrong?
2
Answers
Try this:
Please try this –