I'm trying to create a basic blog archive page with posts listed and grouped by date, according to the instructions in https://toolset.com/2013/10/how-to-group-views-results-by-year-and-month/.
I created the Custom Code snippet following the instructions. I pasted in the Loop content following the instructions. I wasn't sure if I should add the shortcode "heading" to my Front-End Content settings, so I tried it with and without.
Included is a screenshot of the Custom Code I pasted in.
Here are the results I'm getting:
hidden link
Clearly the posts aren't getting grouped correctly.
Can you help me get the basic archive working? Thanks!
Hello,
I have tried the document you mentioned above in my localhost in a fresh wordpress installation, it works fine.
I assume you are putting the custom PHP codes here:
Dashboard-> Toolset-> Settings-> Custom code.
If it is, please make sure you have activate the snippet, see our document:
https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/#activating-a-code-snippet
Section "Activating a code snippet".
You can also try to put the custom PHP codes into your theme file "functions.php", and test again.
Hi Luo,
Thank you so much. The snippet was not activated. I activated it and the archive worked as desired.
I have a follow-up question about styling the list of posts.
I want to display the posts as an unordered list within each group of dates. Right now, the "ul" repeats itself each time for the loop, and I am getting spaces in between each item. The Inspector confirms that this is what's happening. See screenshots.
Here's the code I have in the Loop Editor:
[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<wpv-loop>
[heading condition="year" value="[wpv-post-date format="Y"]"]
<h4>[wpv-post-date format="Y"]</h4>
[/heading]
[heading condition="month" value="[wpv-post-date format="F"]"]
<h5>[wpv-post-date format="F"]</h5>
[/heading]
<ul>
<li>[wpv-post-link]</li>
</ul>
</wpv-loop>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-items-found]
<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
[/wpv-no-items-found]
[wpv-layout-end]
Is there any way to get just the "li" items to repeat and not the entire "ul" group?
Thank you for your help.
-Liat
I assume the original question of this thread has been resolved, for other new questions, please check the new thread here:
https://toolset.com/forums/topic/i-want-to-display-the-posts-as-an-unordered-list-within-each-group-of-dates/
My issue is resolved now. Thank you!