Hi to all!
I'm trying to use <?php wp_get_archive('monthly');?> to get only months list for a custom year ... but also limiting with limit=12 it still list months LIFO
How can i get the month list for the years ago?
Hi to all!
I'm trying to use <?php wp_get_archive('monthly');?> to get only months list for a custom year ... but also limiting with limit=12 it still list months LIFO
How can i get the month list for the years ago?
wp_get_archives doesn't have any way to do that. There's a quick hack you can make to let it do it though.
In the general-template.php file, at around line 350, you'll find the wp_get_archives() function. In there, just a few lines down, is this code:
if ( '' != $limit ) {
$limit = (int) $limit;
$limit = ' LIMIT '.$limit;
}
Change that code to this:
if ( '' != $limit ) {
$limit = (int) $limit;
if (!empty($offset)) {
$offset = (int) $offset;
$limit = ' LIMIT '.$offset.','.$limit;
} else {
$limit = ' LIMIT '.$limit;
}
}
That will allow you to specify an offset=number parameter, to skip amounts of time. So an offset of 3 would make it start 3 months ago.
In last thoughts I was wondering something similar...
Do you think we could submit a feature request for this?
So limit could be declared as limit=12,3 for example...
I don't like to hack main code. I prefer to copy entire the function and rewrite it in my theme's functions.php
If you eliminate the $limit = (int) $limit; line, then your suggestion will work fine. The problem is that this is a bit of a security hole (although not a particularly big one, you'd need access to the theme files to exploit it).
Just let editing templates by the admin interface could be the same securiti "hole" Because internal user attacker could write a custom $wpdb function to get things done...
I know this is old but I found some info and made a small tut that might help out.
WordPress Offset Archive Hack
This topic has been closed to new replies.