{"id":2110,"date":"2014-10-28T18:38:52","date_gmt":"2014-10-28T18:38:52","guid":{"rendered":"http:\/\/musilda.cz\/?p=2110"},"modified":"2014-10-28T18:38:52","modified_gmt":"2014-10-28T18:38:52","slug":"funkce-has_post_thumbnail","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/funkce-has_post_thumbnail\/","title":{"rendered":"Funkce has_post_thumbnail"},"content":{"rendered":"
Dne\u0161n\u00ed p\u0159\u00edr\u016fstek do codexu je jednoduch\u00e1 funkce, kter\u00e1 zji\u0161\u0165uje, zda m\u00e1 post p\u0159i\u0159azen\u00fd n\u00e1hledov\u00fd obr\u00e1zek. Pokud \u0161ablona nepodporuje n\u00e1hledov\u00e9 obr\u00e1zky, funkce bude st\u00e1le vrace false.<\/p>\n
Pou\u017eit\u00ed<\/p>\n
has_post_thumbnail( $post_id );<\/pre>\nFunkce vrac\u00ed true, pokud obr\u00e1zek existuje a false, pokud ne.<\/p>\n
$post_id je id postu, kter\u00fd chceme prov\u011b\u0159it. Pokud se funkce nach\u00e1z\u00ed uvnit\u0159 loopu, nen\u00ed pot\u0159eba $post_id vypl\u0148ovat.
\nPokud vol\u00e1te funkci mimo loop, je pot\u0159eba $post_id pou\u017e\u00edt.<\/p>\n
Hojn\u011b je vyu\u017e\u00edvan\u00e1 v \u0161ablon\u00e1ch, kde zobraz\u00ed n\u00e1hledov\u00fd obr\u00e1zek a pokud neexistuje, nahrad\u00ed jej n\u011bjak\u00fdm defaultn\u00edm.<\/p>\n
if ( has_post_thumbnail() ) {\n\tthe_post_thumbnail();\n}\nelse {\n\techo '
';\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"Dne\u0161n\u00ed p\u0159\u00edr\u016fstek do codexu je jednoduch\u00e1 funkce, kter\u00e1 zji\u0161\u0165uje, zda m\u00e1 post p\u0159i\u0159azen\u00fd n\u00e1hledov\u00fd obr\u00e1zek. Pokud \u0161ablona nepodporuje n\u00e1hledov\u00e9 obr\u00e1zky, funkce bude st\u00e1le vrace false.<\/p>\n","protected":false},"author":1,"featured_media":8523,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,15],"tags":[],"class_list":["post-2110","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-codex","category-post-funkce"],"_links":{"self":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/2110"}],"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=2110"}],"version-history":[{"count":0,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/2110\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media\/8523"}],"wp:attachment":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media?parent=2110"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/categories?post=2110"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/tags?post=2110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}