0

Hey WordPress Development,

Currently, I have to create a list of months based on the date query of custom posts I have for the current year. I am probably not saying this right so hopefully my format example below is some help.

So if I have 30 posts for July and 15 posts for August I want to create two links that read like this...

<a href="/data/?m=Aug">August</a>
<a href="/data/?m=Jul">July</a>

I don't think I could use a wp_archives because I need to output this format. Reason being is I'm doing a some ajax functions on the page and it's easier to just use $_GET variable.

Thank you in advance.

Edit I guess a better way of asking is... How do I display the most recent post from each month?

  • What are your inputs? Where do months come from? – Rarst Aug 19 '16 at 13:32
  • Not sure what you mean but inputs. But I'm trying to use the date of the posts for the month. – kcroake88 Aug 19 '16 at 13:34
  • Why does your example have July and August? Where do you have 30/15 example posts and how? – Rarst Aug 19 '16 at 13:35
  • OH gotcha, July and August are just the two months worth of data I have populated. Basically, I'm using posts because a client will be adjusting a data points for each day of the month. I then want to take those posts and make a query to make a link to each month. So right now I wrote a wp_query that lists all the posts but instead of I want it to list the months with posts. Does that make sense? It's really hard for me to explain technical things sometimes. – kcroake88 Aug 19 '16 at 13:41
  • I guess a better way of asking is... How do I display the most recent post from each month? – kcroake88 Aug 19 '16 at 13:55
-1

Try This

<a href="/2016/8/?post_type=post">August</a>
<a href="/2016/7/?post_type=post">July</a>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.