{"id":451,"date":"2014-06-07T11:40:09","date_gmt":"2014-06-07T11:40:09","guid":{"rendered":"http:\/\/localhost\/__sites\/3d_blog\/?p=451"},"modified":"2014-06-07T11:49:33","modified_gmt":"2014-06-07T11:49:33","slug":"sidebar-count-with-style-revisited","status":"publish","type":"post","link":"http:\/\/blog.silverterra.net\/?p=451","title":{"rendered":"sidebar count with style revisited"},"content":{"rendered":"<blockquote><p>Goal: fix all the sidebar list (archives by &#8230;, categories)<\/p><\/blockquote>\n<p>I did this correction earlier on categories list ( see also: <a href=\"?p=94\" title=\"category count with style\">category count with style<\/a> ).<br \/>\nI will do this on archives list as well based on the previous solution and overriding that one.<br \/>\n<strong>1. get the archives list with count:<\/strong><\/p>\n<pre data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">\r\nwp_get_archives('type=monthly&amp;show_post_count=1');\r\n<\/pre>\n<p><strong>2. counter changes:<\/strong><br \/>\nWe have numbers between parentheses but this is not good I need to wrap the numbers into a span.<br \/>\nAdd this to the end of the <strong>functions.php<\/strong> file. <span class=\"red\">This change is for all sidebar lists!<\/span><\/p>\n<pre data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">\r\n...\r\n\/* added functions *\/\r\nadd_filter('get_archives_link', 'wrap_counter_to_span' );\r\nfunction wrap_counter_to_span($links) {\r\n  $links = str_replace('(', '&lt;span class=&quot;cnt&quot;&gt;(', $links);\r\n  $links = str_replace(')', ')&lt;\/span&gt;', $links);\r\n  return $links;\r\n}\r\n<\/pre>\n<p>This change affects the category list creation as well!<br \/>\nNow we need a simple style definition in our <strong>style.css<\/strong> file.<\/p>\n<pre data-enlighter-language=\"css\" class=\"EnlighterJSRAW\">\r\n#sidebar span.cnt{\r\n  font: 10px Verdana, 'Lucida Grande', Arial, Sans-Serif;\r\n}\r\n<\/pre>\n<blockquote><p>see also: <a href=\"?p=94\" title=\"category count with style\">category count with style<\/a><\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Goal: fix all the sidebar list (archives by &#8230;, categories) I did this correction earlier on categories list ( see also: category count with style ). I will do this on archives list as well based on the previous solution and overriding that one. 1. get the archives list with count: 2. counter changes: We [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-451","post","type-post","status-publish","format-standard","hentry","category-wordpress"],"_links":{"self":[{"href":"http:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/posts\/451","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.silverterra.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=451"}],"version-history":[{"count":9,"href":"http:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/posts\/451\/revisions"}],"predecessor-version":[{"id":460,"href":"http:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/posts\/451\/revisions\/460"}],"wp:attachment":[{"href":"http:\/\/blog.silverterra.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=451"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.silverterra.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=451"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.silverterra.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=451"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}