Category page that allows user to switch between alphabetical and by-date
-
Hi,
I am updating my theme and I am trying to find a better solution for an issue that works perfectly but only by using very bad practices!
I have category pages with this at the top: ALPHABETICAL | BY DATE The first is greyed out and the second is a link.
When the user arrives the categories are displayed alphabetically. The user can choose to see them by date if they prefer by clicking on the link. This works by having the category page display alphabetically, while the “by date” option sends you to a page which uses a template that contains a date based loop.
The bad practice involved (which I want to get rid of) is that this option does not sit properly inside the theme. Switching between views should be a theme-specific option and shouldn’t require any extra kludges.
I have been trying to work out a way in which the “by date” anchor tag can call a file (“category-by-date.php”), or call a template part – but so far either nothing happens or the file is included from the moment the page loads and not when the link is clicked. I have tried including both loops in one file and working out a way of switching between them…
I am now baffled. Does anyone have an idea of how I should proceed?
Cheers
Owen
- The topic ‘Category page that allows user to switch between alphabetical and by-date’ is closed to new replies.