{"id":2343,"date":"2015-04-08T17:34:32","date_gmt":"2015-04-08T17:34:32","guid":{"rendered":"http:\/\/musilda.cz\/?p=2343"},"modified":"2015-04-08T17:34:32","modified_gmt":"2015-04-08T17:34:32","slug":"jak-zmenit-razeni-prispevku-od-nejstarsiho-k-nejnovejsimu","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/jak-zmenit-razeni-prispevku-od-nejstarsiho-k-nejnovejsimu\/","title":{"rendered":"Jak zm\u011bnit \u0159azen\u00ed p\u0159\u00edsp\u011bvk\u016f od nejstar\u0161\u00edho k nejnov\u011bj\u0161\u00edmu"},"content":{"rendered":"

Dne\u0161n\u00ed snippet bude velmi jednoduch\u00fd, ale proto\u017ee se mne na to pt\u00e1 ji\u017e n\u011bkolik\u00e1t\u00fd \u010dlov\u011bk, mysl\u00edm, \u017ee bude u\u017eite\u010dn\u00e9 jej zde zapsat.<\/p>\n

Vzhledem k tomu, \u017ee m\u00e1 WordPress \u0159adu akc\u00ed a filtr\u016f, bude snadn\u00e9 vyu\u017e\u00edt filter\u00a0pre_get_posts.<\/p>\n

A pak ji\u017e jen sta\u010d\u00ed zjistit, zda se jedn\u00e1 o arch\u00edv a zm\u011bnid \u0159azen\u00ed z desc na asc.<\/p>\n

\nadd_filter( 'pre_get_posts' , 'my_change_order' );\nfunction my_change_order( $query ) {\n\tif($query->is_archive)\n\t\t$query->set( 'order' , 'asc' );\n\treturn $query;\n}\n<\/pre>\n

Jak jsem psal, dnes to bylo kr\u00e1tk\u00e9.<\/p>\n","protected":false},"excerpt":{"rendered":"

Dne\u0161n\u00ed snippet bude velmi jednoduch\u00fd, ale proto\u017ee se mne na to pt\u00e1 ji\u017e n\u011bkolik\u00e1t\u00fd \u010dlov\u011bk, mysl\u00edm, \u017ee bude u\u017eite\u010dn\u00e9 jej zde zapsat. Vzhledem k tomu, \u017ee m\u00e1 WordPress \u0159adu akc\u00ed a filtr\u016f, bude snadn\u00e9 vyu\u017e\u00edt filter\u00a0pre_get_posts. A pak ji\u017e jen sta\u010d\u00ed zjistit, zda se jedn\u00e1 o arch\u00edv a zm\u011bnid \u0159azen\u00ed z desc na asc. add_filter(<\/p>\n","protected":false},"author":1,"featured_media":1978,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[355],"class_list":["post-2343","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-snippety","tag-snippet"],"_links":{"self":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/2343"}],"collection":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/comments?post=2343"}],"version-history":[{"count":0,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/2343\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media\/1978"}],"wp:attachment":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media?parent=2343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/categories?post=2343"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/tags?post=2343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}