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 forget_archive
Categories::
2.1
getarchives_join
andgetarchives_where
filters: They work well when is just one archive. Then you can modify the query one archive. Problem: I need more than one archive2.2 adding templates,
template_include
filter and global variable: this allowed me to have a global variable with the corresponding template name (category-blog.php
,category-news.php
andcategory-archive.php
). With those names I could change thegetarchives_where
accordingly. Problem: This almost work until I realized that the widget links for the archive point to something likemysite.com/2012/02
and 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 permalinkmysite.com/2012/02
to something likemysite.com/news/2012/02
. Then I can use$_SERVER['REQUEST_URI']
in thegetarchives_where
. Problem: I have no idea how to modify themysite.com/2012/02
. I research,get_month_link
andget_year_link
. There is no category parameter.Using custom post type:: Obviously I needed
archive-news.php
,archive-blog.php
andarchive-gallery.php
and add to mygetarchives_where
of 2.2. I crashed intoCustom Post Type
. I created and register the three custom post types: Blog, News and Gallery.3.1 The
has_archive
delusion: 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_include
filter and global variable: This is similar to 2.2 but witharchive-blog.php
andarchive-gallery.php
. Problem: Exactly the same as 2.2. The widget links for the archive point to something likemysite.com/2012/02
and 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 still4.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?