{"id":27646,"date":"2013-03-31T11:39:28","date_gmt":"2013-03-31T10:39:28","guid":{"rendered":"https:\/\/pl.wordpress.org\/support\/topic\/kolejnosc-tagow\/"},"modified":"2016-08-05T21:55:28","modified_gmt":"2016-08-05T21:55:28","slug":"kolejnosc-tagow","status":"closed","type":"topic","link":"https:\/\/pl.wordpress.org\/support\/topic\/kolejnosc-tagow\/","title":{"rendered":"Kolejno\u015b\u0107 tag\u00f3w"},"content":{"rendered":"<p>W moim szablonie kolejno\u015b\u0107 tag\u00f3w jest alfabetycznie, ale w dziwny spos\u00f3b. Kolejno\u015b\u0107 jest A-Z-A, czyli wy\u015bwietla tagi arbuz-banan-ananas. Chc\u0119 przerobi\u0107 to, \u017ceby wy\u015bwietla\u0142o poprawnie, A-Z.<\/p>\n<p>Je\u017celi dobrze zrozumia\u0142em to w poni\u017cszym kawa\u0142ku zmienia si\u0119 ich kolejno\u015b\u0107, ale jakkolwiek pr\u00f3buj\u0119, to jedynie zmienia kolejno\u015b\u0107 na co najwy\u017cej Z-A-Z, jak powinienem zmieni\u0107, \u017ceby wy\u015bwietla\u0142o tagi tylko A-Z?<\/p>\n<pre><code>$defaults = array(\n\t\t&#039;smallest&#039; =&gt; 8, &#039;largest&#039; =&gt; 22, &#039;unit&#039; =&gt; &#039;pt&#039;, &#039;number&#039; =&gt; 45,\n\t\t&#039;format&#039; =&gt; &#039;flat&#039;, &#039;separator&#039; =&gt; &quot;\\n&quot;, &#039;orderby&#039; =&gt; &#039;name&#039;, &#039;order&#039; =&gt; &#039;ASC&#039;,\n\t\t&#039;exclude&#039; =&gt; &#039;&#039;, &#039;include&#039; =&gt; &#039;&#039;, &#039;link&#039; =&gt; &#039;view&#039;, &#039;taxonomy&#039; =&gt; &#039;post_tag&#039;, &#039;echo&#039; =&gt; true\n);<\/code><\/pre>\n<p>Dla pewno\u015bci daj\u0119 ca\u0142y plik z tagami:<\/p>\n<pre><code>&lt;?php\n\/**\n* @package   Warp Theme Framework\n* @author    YOOtheme http:\/\/www.yootheme.com\n* @copyright Copyright (C) YOOtheme GmbH\n* @license   YOOtheme Proprietary Use License (http:\/\/www.yootheme.com\/license)\n*\/\n\n\/\/ sort tags\nif (!function_exists(&#039;_count_sort&#039;)) {\n\n\tfunction _count_sort(&amp;$tags) {\n\t\t\t$tags = array_merge($tags);\n\t\t\t$sorted_tags = array();\n\t\t\t$prefix = 1;\n\t\t\tfor ($i = 0; $i &lt; count($tags); $i++) {\n\t\t\t\t$sorted_tags[(int)((count($tags) + ($prefix * $i)) \/ 2)] = $tags[$i];\n\t\t\t\t$prefix *= -1;\n\t\t\t}\n\t\t\tksort($sorted_tags);\n\t\t\t$tags = $sorted_tags;\n\t}\n\n}\n\n$taxonomy = (!empty($module-&gt;params[&#039;taxonomy&#039;]) &amp;&amp; taxonomy_exists($module-&gt;params[&#039;taxonomy&#039;])) ? $module-&gt;params[&#039;taxonomy&#039;] : &#039;post_tag&#039;;\n\n$defaults = array(\n\t\t&#039;smallest&#039; =&gt; 8, &#039;largest&#039; =&gt; 22, &#039;unit&#039; =&gt; &#039;pt&#039;, &#039;number&#039; =&gt; 45,\n\t\t&#039;format&#039; =&gt; &#039;flat&#039;, &#039;separator&#039; =&gt; &quot;\\n&quot;, &#039;orderby&#039; =&gt; &#039;name&#039;, &#039;order&#039; =&gt; &#039;ASC&#039;,\n\t\t&#039;exclude&#039; =&gt; &#039;&#039;, &#039;include&#039; =&gt; &#039;&#039;, &#039;link&#039; =&gt; &#039;view&#039;, &#039;taxonomy&#039; =&gt; &#039;post_tag&#039;, &#039;echo&#039; =&gt; true\n);\n\n$tags = get_terms($taxonomy, array_merge($defaults, array(&#039;orderby&#039; =&gt; &#039;count&#039;, &#039;order&#039; =&gt; &#039;DESC&#039;)));\n\nif (empty($tags)) return;\n\nforeach ($tags as $key =&gt; $tag) {\n\n    $link = get_term_link( intval($tag-&gt;term_id), $taxonomy );\n\n\tif (is_wp_error($link)) return;\n\n\t$tags[ $key ]-&gt;link = $link;\n\t$tags[ $key ]-&gt;id = $tag-&gt;term_id;\n}\n\n_count_sort($tags);\n\n$counts = array();\n$real_counts = array(); \/\/ For the alt tag\n\nforeach ((array) $tags as $key =&gt; $tag) {\n\t$real_counts[ $key ] = $tag-&gt;count;\n\t$counts[ $key ] = round(log10($tag-&gt;count + 1) * 100);\n}\n\n$min_count = min( $counts );\n$max_count = max( $counts );\n\n$font_span = ($max_count - $min_count) \/ 100;\n$font_class_span = (10 - 1) \/ 100;\n\necho &#039;&lt;ul class=&quot;blank tagcloud&quot;&gt;&#039;;\nforeach ( $tags as $key =&gt; $tag ) {\n\n\t$count = $counts[ $key ];\n\t$tag_link = &#039;#&#039; != $tag-&gt;link ? esc_url( $tag-&gt;link ) : &#039;#&#039;;\n\t$tag_name = $tags[ $key ]-&gt;name;\n\t$weight = $font_span ? round(1 + (($count - $min_count) \/ $font_span) * $font_class_span) : 1;\n\n\t$tag_description = $tag-&gt;description;\n\n\tif ($tag_description == &#039;&#039;)\n\t\t{\n\t\t\techo &#039;&lt;li class=&quot;weight&#039;.$weight.&#039;&quot;&gt;&lt;a class=&quot;chmura&quot; href=&quot;&#039;.$tag_link.&#039;&quot;&gt;&#039;.$tag_name.&#039;&lt;span&gt;Tag nie ma jeszcze opisu.&lt;\/span&gt;&lt;\/a&gt; | &lt;\/li&gt;&#039;;\n\t\t}\n\telse\n\t\t{\n\t\t\techo &#039;&lt;li class=&quot;weight&#039;.$weight.&#039;&quot;&gt;&lt;a class=&quot;chmura&quot; href=&quot;&#039;.$tag_link.&#039;&quot;&gt;&#039;.$tag_name.&#039;&lt;span&gt;&#039;.$tag_description.&#039;&lt;\/span&gt;&lt;\/a&gt; | &lt;\/li&gt;&#039;;\n\t\t}\n}\necho &#039;&lt;\/ul&gt;&#039;;<\/code><\/pre>\n<p>Pr\u00f3bowa\u0142em plugin\u00f3w, ale dop\u00f3ki tutaj nie zmieni\u0119 zawsze b\u0119dzie wy\u015bwietla\u0107 w potr\u00f3jnej kolejno\u015bci, np mam 40 tag\u00f3w, 1-40-1 i co drugi tag jest od ko\u0144ca.<\/p>\n","protected":false},"template":"","class_list":["post-27646","topic","type-topic","status-closed","hentry","topic-tag-order","topic-tag-tag","topic-tag-tag-order"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/pl.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/27646","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pl.wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/pl.wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/pl.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/27646\/revisions"}],"wp:attachment":[{"href":"https:\/\/pl.wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=27646"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}