{"id":181,"date":"2004-11-14T00:51:36","date_gmt":"2004-11-13T22:51:36","guid":{"rendered":"http:\/\/www.all-things-me.net\/blog\/archives\/2004\/11\/14\/category-and-archive-droppings"},"modified":"2010-08-12T02:02:25","modified_gmt":"2010-08-11T23:02:25","slug":"category-and-archive-droppings","status":"publish","type":"post","link":"https:\/\/www.all-things-me.net\/blog\/2004\/11\/14\/category-and-archive-droppings","title":{"rendered":"Category and archive droppings"},"content":{"rendered":"<p>In the attempt to shorten the menu, I decided to put the lists of monthly archives and categories into drop down menus. I just realized that in time they will (at least the monthly archives) get longer and longer and longer&#8230;<\/p>\n<p>So, my first problem was that I&#8217;ve made a hidden category for static pages and it would show on the menu if I used WP&#8217;s built-in dropdown_cats tag. <\/p>\n<p>Luckily, Ria at <a href=\"http:\/\/www.typedby.com\/\">Typed by<\/a> has made a <a href=\"http:\/\/typedby.com\/archives\/2004\/06\/22\/dropdown-plugin-with-ability-to-exclude\/\">Drop Down Cats Plugin<\/a> with ability to exclude. What&#8217;s nice about it is that it a) formats subcategories differently from parents (indented with a hyphen), and b) it includes a post count parameter.<\/p>\n<p>Archive tag (wp_get_archives) has an option to format the list of archives as an option list. You just need to build a drop-down menu function around it. Thus, as found at <a href=\"http:\/\/wordpress.org\/support\/3\/5661\">the WordPress forums<\/a>&#8230;<br \/>\n(remove the spaces after dots in &#8220;window.location=&#8221; if you&#8217;re going to cut-and-paste that &#8212; I needed to separate the words because it wouldn&#8217;t wrap nicely)<\/p>\n<blockquote class=\"html\"><p>\n&lt;form name=&quot;archiveform&quot; action=&quot;&quot;&gt;<br \/>\n&nbsp;&nbsp;&lt;select name=&quot;monthly_arch&quot; onchange=&quot;window.location = (document. forms. archiveform. monthly_arch[document. forms. archiveform. monthly_arch. selectedIndex].value);&quot;&gt;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;option selected&gt;Monthly archives&lt;\/option&gt;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php <a href=\"http:\/\/wiki.wordpress.org\/wp_get_archives\">wp_get_archives<\/a>(&#039;type=monthly&amp;format=option&#039;); ?&gt;<br \/>\n&nbsp;&nbsp;&lt;\/select&gt;<br \/>\n&lt;\/form&gt;\n<\/p><\/blockquote>\n<p>It includes a little JavaScript, but I don&#8217;t know if that can be avoided. I&#8217;m disappointed to notice that formatting the archives as options is not compatible with showing the post count.<br \/>\n<i>But<\/i><br \/>\nIn <a href=\"http:\/\/wordpress.org\/support\/3\/5661#post-79879\">the same thread<\/a> there was a solution to that too. It involves a little tweaking (or correcting&#8230;) in template-functions-general.php, function <code>get_archives_link<\/code> around line 180, changing<\/p>\n<blockquote class=\"php\"><p>\nelse if (&#039;option&#039; == $format) {<br \/>\nreturn &#039;&lt;option value=&quot;&#039;.$url.&#039;&quot;&gt;&#039;.$text.&#039;&lt;\/option&gt;&#039;.&quot;&#92;n&quot;;\n<\/p><\/blockquote>\n<p>to<\/p>\n<blockquote class=\"php\"><p>\nelse if (&#039;option&#039; == $format) {<br \/>\nreturn &#039;&lt;option value=&quot;&#039;.$url.&#039;&quot;&gt;&#039;.$text<strong>.$after.<\/strong>&#039;&lt;\/option&gt;&#039;.&quot;&#92;n&quot;;<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>In the attempt to shorten the menu, I decided to put the lists of monthly archives and categories into drop down menus. I just realized that in time they will (at least the monthly archives) get longer and longer and longer&#8230; So, my first problem was that I&#8217;ve made a hidden category for static pages [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15,18],"tags":[],"class_list":["post-181","post","type-post","status-publish","format-standard","hentry","category-tweaks","category-wordpress"],"_links":{"self":[{"href":"https:\/\/www.all-things-me.net\/blog\/wp-json\/wp\/v2\/posts\/181","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.all-things-me.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.all-things-me.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.all-things-me.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.all-things-me.net\/blog\/wp-json\/wp\/v2\/comments?post=181"}],"version-history":[{"count":2,"href":"https:\/\/www.all-things-me.net\/blog\/wp-json\/wp\/v2\/posts\/181\/revisions"}],"predecessor-version":[{"id":1452,"href":"https:\/\/www.all-things-me.net\/blog\/wp-json\/wp\/v2\/posts\/181\/revisions\/1452"}],"wp:attachment":[{"href":"https:\/\/www.all-things-me.net\/blog\/wp-json\/wp\/v2\/media?parent=181"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.all-things-me.net\/blog\/wp-json\/wp\/v2\/categories?post=181"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.all-things-me.net\/blog\/wp-json\/wp\/v2\/tags?post=181"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}