Grouping Posts by Year and Month

@HoWin I’m still learning a lot about WordPress in Pinegrow, but here is how I did it.

For the year

  1. Place an <h1> where you want your Year to appear on the page
  2. Select the element and add an If Option from the WordPress Actions
  3. For the condition enter $old_year !== $current_year
  4. Next add a PHP Code block from the WP Actions
  5. For the function add echo $current_year and replace the Content
  6. Add a PHP Code 2 block from the WP Actions
  7. For the function add $old_year = $current_year and for replace select Insert after

For the month

  1. Add an <h2> element where you want the month to appear
  2. Select the element and add an If Option from the WP Actions
  3. For the condition enter $old_month !== $current_month
  4. Next add a PHP Code block from the WP Actions
  5. For the function add echo $current_month and replace the Content
  6. Add a PHP Code 2 block from the WP Actions
  7. For the function add $old_month = $current_month and for replace select Insert after

Set-up the variables

I added my variable initiation to the loop - you could probably also add them to the individual elements - thinking about it, that is how I should have done it, but I’m too lazy to go back and redo it! :smiley:

  1. Select loop element
  2. Add a PHP Code block from the WP Actions
  3. For the function add $current_year = get_the_date('Y') and replace Insert before
  4. Add a PHP Code 2 block from the WP Actions
  5. For the function add $current_month = get_the_date('F') and replace Insert before

That should do it! If you need additional help reach out.
Bob