{"id":2394,"date":"2015-05-04T04:19:26","date_gmt":"2015-05-04T04:19:26","guid":{"rendered":"http:\/\/musilda.cz\/?p=2394"},"modified":"2015-05-04T04:19:26","modified_gmt":"2015-05-04T04:19:26","slug":"co-znamena-excerot-neboli-strucny-vypis-prispevku","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/co-znamena-excerot-neboli-strucny-vypis-prispevku\/","title":{"rendered":"Co znamen\u00e1 excerpt neboli stru\u010dn\u00fd v\u00fdpis p\u0159\u00edsp\u011bvku"},"content":{"rendered":"

Excerpt je velmi pou\u017e\u00edvan\u00e1 funkce ve WordPress \u0161ablon\u00e1ch, ale ne v\u017edy se chov\u00e1 tak jak o\u010dek\u00e1v\u00e1me. Pro\u010d je tomu tak a jak\u00fd je rozd\u00edl mezi manu\u00e1ln\u00edm a automatick\u00fdm excerpt.<\/p>\n

Nejprve, co to je zkr\u00e1cen\u00fd v\u00fdpis, neboli excerpt.\u00a0<\/strong><\/p>\n

S t\u00edm se setk\u00e1te v \u0161ablon\u00e1ch velmi \u010dasto a jedn\u00e1 se \u00faryvek textu, kter\u00fd je vytvo\u0159en z \u010d\u00e1sti hlavn\u00edho \u010dl\u00e1nu automaticky. Na druhou stranu m\u016f\u017eete excerpt vytvo\u0159it ru\u010dn\u011b a to vlo\u017een\u00edm textu do boxu „Stru\u010dn\u00fd v\u00fdpis p\u0159\u00edsp\u011bvku“.<\/p>\n

Jak\u00fd je mezi nimi rozd\u00edl?<\/strong><\/p>\n

Ru\u010dn\u011b vytvo\u0159en\u00fd excerpt vlo\u017e\u00edte p\u0159i vytv\u00e1\u0159en\u00ed \u010dl\u00e1nku, nebo jeho \u00faprav\u011b, do tohoto textov\u00e9ho pole:<\/p>\n

\"screenshot-musilda.cz<\/a><\/p>\n

 <\/p>\n

D\u00edky tomu z\u00edsk\u00e1te kontrolu nad t\u00edm, co se v\u00e1m ve v\u00fdpise \u010dl\u00e1nk\u016f bude zobrazovat, proto\u017ee WordPress tento z\u00e1znam v\u017edy up\u0159ednostn\u00ed. Ulo\u017een je do sloupce post_excerpt v tabulce wp_posts:<\/p>\n

\"excerpt_in_db\"<\/a><\/p>\n

 <\/p>\n

Pokud budete vypisovat hodnoty postu pomoc\u00ed global $post, bude to $post->post_excerpt. Dal\u0161\u00ed v\u00fdhodou je mo\u017enost pou\u017eit\u00ed html tag\u016f, tak\u017ee m\u016f\u017eete m\u00edt v perexu \u010dl\u00e1nku i odkazy.<\/p>\n

Ale pozor! Pokud pou\u017eijete funkci the_excerpt(), bude automaticky kontrolovat jeho existenci a vy se nemus\u00edte ji\u017e o nic starat.<\/p>\n

 <\/p>\n

Automatick\u00fd excerpt<\/strong><\/p>\n

Automatick\u00fd excerpt se vytvo\u0159\u00ed v p\u0159\u00edpad\u011b, \u017ee \u0161ablona pou\u017e\u00edv\u00e1 funkci the_excerpt() a manu\u00e1ln\u00ed stru\u010dn\u00fd v\u00fdpis nen\u00ed k dispozici. Pak vezme obsah \u010dl\u00e1nku, vyfiltruje z n\u011bj v\u0161echny html tagy a z\u00edskan\u00fd text o\u0159\u00edzne na ur\u010dit\u00fd po\u010det slov.<\/p>\n

Nev\u00fdhodou je, \u017ee ztrat\u00edte kontrolu nad t\u00edm, co p\u0159esn\u011b se zobrazuje v perexu \u010dl\u00e1nku a z\u00e1rove\u0148, pokud m\u00e1te na za\u010d\u00e1tku \u010dl\u00e1nku n\u011bjak\u00fd odkaz, tak ten se v\u00e1m nezobraz\u00ed. Po\u010det slov automatick\u00e9ho excerptu se d\u00e1 ovlivnit pomoc\u00ed filtru a p\u0159\u00edpadn\u00e1 alternativa je pou\u017eit\u00ed funkce wp_trim_words().<\/p>\n

 <\/p>\n","protected":false},"excerpt":{"rendered":"

Excerpt je velmi pou\u017e\u00edvan\u00e1 funkce ve WordPress \u0161ablon\u00e1ch, ale ne v\u017edy se chov\u00e1 tak jak o\u010dek\u00e1v\u00e1me. Pro\u010d je tomu tak a jak\u00fd je rozd\u00edl mezi manu\u00e1ln\u00edm a automatick\u00fdm excerpt. Nejprve, co to je zkr\u00e1cen\u00fd v\u00fdpis, neboli excerpt.\u00a0 S t\u00edm se setk\u00e1te v \u0161ablon\u00e1ch velmi \u010dasto a jedn\u00e1 se \u00faryvek textu, kter\u00fd je vytvo\u0159en z \u010d\u00e1sti<\/p>\n","protected":false},"author":1,"featured_media":2398,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,30],"tags":[133,374],"class_list":["post-2394","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-navody","category-wordpress","tag-excerpt","tag-the_excerpt"],"_links":{"self":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/2394"}],"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=2394"}],"version-history":[{"count":0,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/2394\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media\/2398"}],"wp:attachment":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media?parent=2394"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/categories?post=2394"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/tags?post=2394"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}