webu wp-see.com<\/a>.<\/p>\nTi co rad\u011bji \u010dtou se mohou v\u011bnovat n\u00e1vodu zde v \u010dl\u00e1nku.<\/p>\n
Co budeme pot\u0159ebovat pro child theme?<\/h2>\n
Rodi\u010dovskou \u0161ablonu. Pokud si koup\u00edte \u0161ablonu t\u0159eba na ThemeForest, \u010dasto slo\u017eka, jen\u017e si st\u00e1hnete, obsahuje zip soubor se \u0161ablonou a zip soubor ozna\u010den\u00fd nazev-sablony-child. Pokud ano, m\u00e1te vyhr\u00e1no. Nahrejte ob\u011b slo\u017eky a aktivujte child. M\u00e1te hotovo a d\u00e1l \u010d\u00edst nepot\u0159ebujete.<\/p>\n
Pokud tam ale child nen\u00ed, mus\u00edte si ji vytvo\u0159it. Ve slo\u017ece themes, kde m\u00e1te v\u0161echny \u0161ablony vytvo\u0159te slo\u017eku a nazv\u011bte ji nazev-sablony-child.<\/p>\n
Nyn\u00ed se vra\u0165te do slo\u017eky rodi\u010dovsk\u00e9 \u0161ablony a otev\u0159ete si soubor style.css.<\/p>\n
Na jeho za\u010d\u00e1tku uvid\u00edte tento k\u00f3d:<\/p>\n
\/*\nTheme Name: Test\nTheme URI:\nAuthor: Vladislav Musilek\nAuthor URI: toret.cz\nDescription: Description\nVersion: 1.0.0\nLicense: GNU General Public License v2 or later\nLicense URI: http:\/\/www.gnu.org\/licenses\/gpl-2.0.html\nText Domain: test\nTags:\n*\/\n<\/pre>\nT\u00e9to \u010d\u00e1sti se \u0159\u00edk\u00e1 stylesheet header a je to \u017eivotn\u011b d\u016fle\u017eit\u00e1 sou\u010d\u00e1st \u0161ablony. WordPress podle t\u00e9to \u010d\u00e1sti k\u00f3du zji\u0161\u0165uje existenci \u0161ablony a informace o n\u00ed. Zde vid\u00edte, \u017ee \u0161ablonu jsme nazvali Test.<\/p>\n
Dal\u0161\u00edm krokem je vytvo\u0159en\u00ed pr\u00e1zdn\u00e9ho css souboru style.css ve slo\u017ece child theme. Soubor nemus\u00ed krom\u011b stylesheet headeru obsahovat \u017e\u00e1dn\u00fd jin\u00fd k\u00f3d. Header je v\u0161ak nutn\u00e9 upravit:<\/p>\n
\n\/*\nTheme Name: Test Child\nTheme URI:\nAuthor: Vladislav Musilek\nAuthor URI: toret.cz\nDescription: Test Child Theme\nVersion: 1.0.0\nLicense: GNU General Public License v2 or later\nLicense URI: http:\/\/www.gnu.org\/licenses\/gpl-2.0.html\nTemplate: parenttheme\nText Domain: test\nTags:\n<\/pre>\nT\u00edm m\u00e1me p\u0159ipravenou \u0161ablonu tak, \u017ee ji vid\u00edme v administraci a m\u016f\u017eeme ji aktivovat.
\nV\u0161imn\u011bte si rozd\u00edlu, oproti p\u016fvodn\u00edmu z\u00e1pisu, kdy je nav\u00edc polo\u017eka Template. Ta \u0159\u00edk\u00e1, jak\u00e1 \u0161ablona je te rodi\u010dovsk\u00e1. V\u017edy do n\u00ed zapisujeme n\u00e1zev \u0161lo\u017eky rodi\u010dovsk\u00e9 \u0161ablony, nap\u0159\u00edklad Template: avada.<\/p>\n
Co je\u0161t\u011b mus\u00edme ud\u011blat je, \u017ee WordPressu mus\u00edme \u0159\u00edci, odkud m\u00e1 na\u010d\u00edtat css styly pro \u0161ablonu.<\/p>\n
D\u0159\u00edve se to \u0159e\u0161ilo pomoc\u00ed z\u00e1pisu import ve style.css, ale tato metoda je ji\u017e zavr\u017een\u00e1 a spr\u00e1vn\u00fd zp\u016fsob je pomoc\u00ed enqueue.<\/p>\n
Na\u010dten\u00ed css styl\u016f pro child theme<\/h2>\n
Nyn\u00ed mus\u00edme ve slo\u017ece child \u0161ablony vytvo\u0159it soubor functions.php, tedy stejn\u00fd soubor, jen\u017e se nach\u00e1z\u00ed i v rodi\u010dovsk\u00e9 \u0161ablon\u011b.<\/p>\n
Do n\u011bj vlo\u017e\u00edme tento k\u00f3d:
\n(upraveno 4.12.2015 z d\u016fvodu neaktu\u00e1lnosti k\u00f3du)<\/p>\n
\nadd_action( 'wp_enqueue_scripts', 'your_child_theme_enqueue_styles' );\nfunction your_child_theme_enqueue_styles() {\n \/\/ Parent style id - replace your child theme name\n $parent_style = 'parent-style';\n\n \/\/ Enqueue Parent theme's style\n wp_enqueue_style( $parent_style, get_template_directory_uri() . '\/style.css' );\n \/\/ Enqueue Child theme's style\n wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '\/style.css', array( $parent_style ) );\n\n\n}\n<\/pre>\nHotovo!<\/h2>\n
Child theme m\u00e1te p\u0159ipravenou a m\u016f\u017eete za\u010d\u00edt upravovat \u0161ablonu dle va\u0161ich pot\u0159eb.<\/p>\n
Ur\u010dit\u011b se stane, \u017ee naraz\u00edte na probl\u00e9my, n\u011bkter\u00e9 v\u011bci nejsou \u00fapln\u011b jednoduch\u00e9, ale je to jedin\u00e1 spr\u00e1vn\u00e1 cesta.<\/p>\n
Pozn\u00e1mka:
\nAktu\u00e1ln\u011b je k dispozici p\u0159ipraven\u00e1 child theme, kterou jsi jen st\u00e1hnete, zm\u011bn\u00edte n\u00e1zev slo\u017eky rodi\u010dovsk\u00e9 \u0161ablony a m\u016f\u017eete upravovat – http:\/\/musilda.cz\/child-theme-snadno-a-rychle\/<\/a><\/p>\n <\/p>\n","protected":false},"excerpt":{"rendered":"
Na sobotn\u00ed konferenci jsem zd\u016fraz\u0148oval d\u016fle\u017eitost pou\u017eit\u00ed child themes ve WordPressu. Bohu\u017eel se uk\u00e1zalo, \u017ee ne ka\u017ed\u00fd si dovede p\u0159edstavit, jak vlastn\u011b takov\u00e1 child theme funguje. Kdy\u017e si na v\u00e1\u0161 web nainstalujete \u0161ablonu, tak takovou \u0161ablonu je mo\u017en\u00e9 aktualizovat, pokud tedy autor n\u011bjakou aktualizaci ud\u011bl\u00e1. Nikdo z n\u00e1s v\u0161ak nenajde \u0161ablonu, jen\u017e mu vyhovuje absolutn\u011b.<\/p>\n","protected":false},"author":1,"featured_media":2462,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[12,30,32],"tags":[98],"class_list":["post-2461","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-navody","category-wordpress","category-wordpress-sablony","tag-child-theme"],"_links":{"self":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/2461"}],"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=2461"}],"version-history":[{"count":0,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/2461\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media\/2462"}],"wp:attachment":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media?parent=2461"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/categories?post=2461"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/tags?post=2461"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}