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!
Select loop element
Add a PHP Code block from the WP Actions
For the function add $current_year = get_the_date('Y') and replace Insert before
Add a PHP Code 2 block from the WP Actions
For the function add $current_month = get_the_date('F') and replace Insert before
Many many thanks. Your reply helped me a lot. Your solution works fantastic. I also solved it before, but my variant was much more complicated and cumbersome.
And best of all: I’ve learned a lot.
Great help. Thank you very much
My best regards,
Horst
Find attached the result of your loop. I group entries by “Year-Month” and display them alternating left and right on a vertical timeline.
Hey @schpengle,
If you look at the bottom of the picture before it you can see the named block - ‘PHP Code 2’. Basically, in the WordPress Actions panel there are multiple blocks for adding code into the same action. They need to be named differently for editing purposes, so 1, 2, 3, etc…
Cheers,
Bob