Forum
Filtering archives on the blog by section
Hi,
Is it possible to filter the archives on the blog by section? I currently have two sections with the blog app: 'blog' and 'our-work', but only want the posts from the 'blog' section to appear and be filtered.
I am able to filter the results by section, but where the archives are listed on the page by month and year, it does not filter by section – it displays all posts from both sections.
I've tried using some custom code with AJAX but could not get it to work; so I'm hoping there is a Perch solution to this!
Thanks in advance, K
Can you post your diagnostics and the code you're using to display the archive?
Hi Drew,
Apologies on that, I should have included this to begin with!
I did include an array in the following using 'section' => 'blog:
But that seemed to break the code.
archive.php
Here are my templates excluding the AJAX (as that didn't seem to work):
months_year_link.html:
months_month_link.html:
Diagnostics report:
Thanks, K
perch_blog_date_archive_months()
doesn't take any options. It's a horrible, crufty old function.Would it be better to use something like this?
If that gets you the results you need then, yes, that would be better.
Can you use multiple templates with perch_blog_custom? I've tried combing the two templates (one for year and one for months) and it doesn't output/format correctly.
You can do an if/different on the date, but not on two different formats of the date.
Does the design you're working to require both?
The reason I have the date formats: format="Y" and format="m" was for the slug.
In the design the format should be:
2016 (7) December (3) November (2) October (2)
Where I need the quantity of the posts and the year. But it outputs like this:
() December () () December () () December () () November () () November () () October () () October ()
Hmm, yes, I see what you mean.
I don't think we have a good solution for this at the moment.
No worries drew, I did manage to filter it with <perch:if different /> but have left the quantity out for now as that didn't work with perch_blog_custom();
Thank you for your time!