{"id":2570,"date":"2015-10-25T14:05:51","date_gmt":"2015-10-25T14:05:51","guid":{"rendered":"http:\/\/musilda.cz\/?p=2570"},"modified":"2015-10-25T14:05:51","modified_gmt":"2015-10-25T14:05:51","slug":"terms-dostanou-sva-meta-data-ve-wordpress-4-4","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/terms-dostanou-sva-meta-data-ve-wordpress-4-4\/","title":{"rendered":"Terms dostanou sv\u00e1 meta data ve WordPress 4.4"},"content":{"rendered":"\n
Chce se mi \u0159\u00edct kone\u010dn\u011b. Posty maj\u00ed meta tabulku, u\u017eivatel\u00e9, tak\u00e9, tak termy by ji m\u011bli m\u00edt tak\u00e9.<\/p>\n\n\n\n
Pro\u010d je to tak skv\u011bl\u00e9? Proto\u017ee termy jsou v\u0161echny jednotliv\u00e9 kategorie, tagy, ve WooCommerce to jsou kategorie produkt\u016f a mnoho dal\u0161\u00edch.<\/p>\n\n\n\n
A kdy\u017e jste cht\u011bli kategorii p\u0159idat t\u0159eba obr\u00e1zek, kter\u00fd se bude zobrazovat jen u konkr\u00e9tn\u00ed kategorie a ne u v\u0161ech, museli jste pou\u017e\u00edt r\u016fzn\u00e9 obezli\u010dky, jako je ukl\u00e1d\u00e1n\u00ed dat do option.<\/p>\n\n\n\n
No a to te\u010f skon\u010d\u00ed. <\/strong><\/p>\n\n\n\n Nov\u00e9 funkce pro pr\u00e1ci s term meta:<\/p>\n\n\n\n add_term_meta( $term_id, $meta_key, $meta_value, $unique = false )<\/p>\n\n\n\n delete_term_meta( $term_id, $meta_key, $meta_value = “ )<\/p>\n\n\n\n get_term_meta( $term_id, $meta_key, $single = false )<\/p>\n\n\n\n update_term_meta( $term_id, $meta_key, $meta_value, $prev_value = “ )<\/p>\n\n\n\n update_termmeta_cache( $term_ids )<\/p>\n\n\n\n Vid\u00edte, \u017ee jsou funkce obdobn\u00e9 klasick\u00fdm post meta, ale to nejsou jedin\u00e9 zm\u011bny. Nap\u0159\u00edklad get_term z\u00edsk\u00e1 do argument\u016f nov\u00e9 meta_query, funguj\u00edc\u00ed obdobn\u011b, jako u wp_query.<\/p>\n\n\n\n V\u0161echna data budou ukl\u00e1d\u00e1na do datab\u00e1zov\u00e9 tabulky {$wpdb->prefix}termmeta.<\/p>\n\n\n\n Sch\u00e9ma pro tabulku:<\/p>\n\n\n\n Up\u0159\u00edmn\u011b se na tuto zm\u011bnu t\u011b\u0161\u00edm a zaj\u00edmav\u00e1 tak\u00e9 bude z\u00e1plava plugin\u016f, kter\u00e9 se se zm\u011bnou vyroj\u00ed.<\/p>\n","protected":false},"excerpt":{"rendered":" Chce se mi \u0159\u00edct kone\u010dn\u011b. Posty maj\u00ed meta tabulku, u\u017eivatel\u00e9, tak\u00e9, tak termy by ji m\u011bli m\u00edt tak\u00e9. Pro\u010d je to tak skv\u011bl\u00e9? Proto\u017ee termy jsou v\u0161echny jednotliv\u00e9 kategorie, tagy, ve WooCommerce to jsou kategorie produkt\u016f a mnoho dal\u0161\u00edch. A kdy\u017e jste cht\u011bli kategorii p\u0159idat t\u0159eba obr\u00e1zek, kter\u00fd se bude zobrazovat jen u konkr\u00e9tn\u00ed kategorie<\/p>\n","protected":false},"author":1,"featured_media":8647,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[48,30],"tags":[467],"class_list":["post-2570","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-novinky","category-wordpress","tag-wordpress-4-4"],"_links":{"self":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/2570"}],"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=2570"}],"version-history":[{"count":0,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/2570\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media\/8647"}],"wp:attachment":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media?parent=2570"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/categories?post=2570"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/tags?post=2570"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}CREATE TABLE $wpdb->termmeta (\n meta_id bigint(20) unsigned NOT NULL auto_increment,\n term_id bigint(20) unsigned NOT NULL default '0',\n meta_key varchar(255) default NULL,\n meta_value longtext,\n PRIMARY KEY (meta_id),\n KEY term_id (term_id),\n KEY meta_key (meta_key($max_index_length))\n) $charset_collate;<\/pre>\n\n\n\n