I’m designing a theme and want to know if the following is possible:
For my archives section I have the layout like this
<ul> <li class="first_item">most recent month</li> <li>next month</li> <li>etc</li> </ul>
In order for this to display properly I need to call wp_get_archives() but some how limit it to get the most recent archive only, then generate the rest of the archive items as normal with the default
- tags, excluding the most recent.
So my question is not how to limit what archives to get but how do I keep track of the first one I’ve retrieved and separate it from the rest of the archives? Or how to exclude archives?
So basically it needs to look something like this:
<h3>Archives</h3> <ul> <?php wp_get_archives(get the most recent month with custom formating, etc.); ?> <?php wp_get_archives(exclude the most recent month archive, but get the rest, no formating); ?> </ul>
I’ve noticed that there are exclude parameters you can pass to other wp functions but didn’t see it mentioned with this particular function.
You might have to ‘settle’ for something like what was discussed on this thread, unless you can find an archive plugin that handles your requirement (or you develop your own).
Okay, well I didn’t design a plugin but I modified the funtion wp_get_archives().
In the if else section where it checks the type I simply added another count variable $archive_id that updates everytime the function loops through the result set, then added the $archive_id as a parameter to get_archives_link().
When get_archives_link() is formatting your lists it automatically adds the $archive_id to the
<li>tag or whichever on depending on the parameter you set with wp_get_archives().
This way all archive list items have a unique id which you can style. Using a number is a bit non-descriptive but just wanted to see if this could work.
I’ll figure out how to create a plugin and submit it, I’m sure I’m not the only one who would need this functionality.
- The topic ‘querying wp_get_archives()’ is closed to new replies.