Please read the whole question before assuming this question is repeated. After one day of trying plugins and tutorials, I am convinced that there is no straightforward method of achieving what I am trying.
Basically I am building a site that has different components: Blog, News and Gallery, they are all items in the menu. I am trying to have different archive widgets for all of them. So, when I go to News I can see my Archive Widget that just organizes information for News. The same for Blog or Gallery.
What have I tried?
get_archives: there is no category parameter for
getarchives_wherefilters: They work well when is just one archive. Then you can modify the query one archive. Problem: I need more than one archive
2.2 adding templates,
template_includefilter and global variable: this allowed me to have a global variable with the corresponding template name (
category-archive.php). With those names I could change the
getarchives_whereaccordingly. Problem: This almost work until I realized that the widget links for the archive point to something like
mysite.com/2012/02and use a different common template 'archive.php' (see 3 for using custom post type).
2.3 category in permalink and (
$_SERVER['REQUEST_URI']): this is more elegant than grabbing the permalink
mysite.com/2012/02to something like
mysite.com/news/2012/02. Then I can use
getarchives_where. Problem: I have no idea how to modify the
mysite.com/2012/02. I research,
get_year_link. There is no category parameter.
Using custom post type:: Obviously I needed
archive-gallery.phpand add to my
getarchives_whereof 2.2. I crashed into
Custom Post Type. I created and register the three custom post types: Blog, News and Gallery.
has_archivedelusion: The parameter was there and I was convinced I got it. So I went to the news archive (
mysite.com/news) and the archive was there. It worked on the right side displaying the news. The problem: The archive widget was still displaying the normal posts.
3.2 adding the archive templates to the
template_includefilter and global variable: This is similar to 2.2 but with
archive-gallery.php. Problem: Exactly the same as 2.2. The widget links for the archive point to something like
mysite.com/2012/02and again using the the default common template 'archive.php' instead of the ones I created.
Plugins: I don't want to use a plugin for this but I did and didn't work.
4.1. jquery-archive-list-widget: almost work except it works with exclude categories instead of include them. Problem: The link is still
mysite/2012/20/. I am about to modify this plugin but I am still
4.2. I tried a few others with less success.
How do I have different archive widgets according to category/post_type that appears according to the page I am?