{"id":789,"date":"2013-07-12T17:07:46","date_gmt":"2013-07-12T17:07:46","guid":{"rendered":"http:\/\/musilda.cz\/?p=789"},"modified":"2013-07-12T17:07:46","modified_gmt":"2013-07-12T17:07:46","slug":"jak-pridat-atribut-nofollow-vsem-odkazum-z-clanku-na-vasem-wordpress-web","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/jak-pridat-atribut-nofollow-vsem-odkazum-z-clanku-na-vasem-wordpress-web\/","title":{"rendered":"Jak p\u0159idat atribut nofollow v\u0161em odkaz\u016fm z \u010dl\u00e1nk\u016f na va\u0161em WordPress web"},"content":{"rendered":"

S neust\u00e1l\u00fdmi zm\u011bnami algoritmu vyhled\u00e1va\u010d\u016f se objevuje \u0159ada zp\u016fsob\u016f, jak se chr\u00e1nit p\u0159ed penalizac\u00ed. Jednou z nej\u010dast\u011bj\u0161\u00edch rad je p\u0159id\u00e1vat k odkaz\u016fm atribut nofollow. Pokud m\u00e1te web s deseti \u010dl\u00e1nky, tak si jej m\u016f\u017eete doplnit ru\u010dn\u011b, ale co kdy\u017e t\u011bch \u010dl\u00e1nk\u016f m\u00e1te stovky? Proch\u00e1zet jeden po druh\u00e9m by bylo peklo. Proto dnes p\u0159in\u00e1\u0161\u00edm tip na vyu\u017eit\u00ed filtru the_content, pomoc\u00ed se ostatn\u011b d\u00e1 d\u011blat spousta v\u011bc\u00ed, a funkci pro p\u0159id\u00e1n\u00ed nofollow pro v\u0161echny odkazy v \u010dl\u00e1nc\u00edch.<\/p>\n

Nejprve vytvo\u0159\u00edme funkci, kter\u00e1 se provede ve chv\u00edli, kdy bude WordPress vypisovat obsah \u010dl\u00e1nku. Proto, aby se provedla pr\u00e1v\u011b v tuto chv\u00edli, ji p\u0159i\u0159ad\u00edme k filtru the_content.<\/p>\n

\nfunction my_add_nofollow_function($text) {\n\n}\nadd_filter('the_content','my_add_nofollow_function');\n<\/pre>\n

Pro samotn\u00e9 p\u0159id\u00e1n\u00ed atributu nofollow pou\u017eijeme funkci WordPressu wp_rel_nofollow(). Samotn\u00e1 funkce vypad\u00e1 takto:<\/p>\n

\nfunction wp_rel_nofollow( $text ) {\n\t\/\/ This is a pre save filter, so text is already escaped.\n\t$text = stripslashes($text);\n\t$text = preg_replace_callback('||i', 'wp_rel_nofollow_callback', $text);\n\t$text = esc_sql($text);\n\treturn $text;\n}\n<\/pre>\n

Do na\u0161\u00ed funkce vlo\u017e\u00edme n\u00e1sleduj\u00edc\u00ed k\u00f3d:<\/p>\n

\n $text = stripslashes(wp_rel_nofollow($text));\n<\/pre>\n

V\u00fdsledek vlo\u017e\u00edme do functions.php :<\/p>\n

\nfunction my_add_nofollow_function($text) {\n   $text = stripslashes(wp_rel_nofollow($text));\n\n   return $text;\n}\nadd_filter('the_content','my_add_nofollow_function');\n<\/pre>\n

Takto jednoduch\u00e1 funkce n\u00e1m u\u0161et\u0159\u00ed mnoho pr\u00e1ce a \u010dasu s proch\u00e1zen\u00edm webu a ru\u010dn\u00edm p\u0159id\u00e1v\u00e1n\u00edm nofollow.
\nSamotn\u00e1 funkce by se dala upravit i tak, aby p\u0159id\u00e1vala atribut jen k odkaz\u016fm na konkr\u00e9tn\u00ed dom\u00e9ny, ale to u\u017e vy\u017eaduje znalost regul\u00e1rn\u00edch v\u00fdraz\u016f.<\/p>\n","protected":false},"excerpt":{"rendered":"

S neust\u00e1l\u00fdmi zm\u011bnami algoritmu vyhled\u00e1va\u010d\u016f se objevuje \u0159ada zp\u016fsob\u016f, jak se chr\u00e1nit p\u0159ed penalizac\u00ed. Jednou z nej\u010dast\u011bj\u0161\u00edch rad je p\u0159id\u00e1vat k odkaz\u016fm atribut nofollow. Pokud m\u00e1te web s deseti \u010dl\u00e1nky, tak si jej m\u016f\u017eete doplnit ru\u010dn\u011b, ale co kdy\u017e t\u011bch \u010dl\u00e1nk\u016f m\u00e1te stovky? Proch\u00e1zet jeden po druh\u00e9m by bylo peklo. Proto dnes p\u0159in\u00e1\u0161\u00edm tip na<\/p>\n","protected":false},"author":1,"featured_media":8624,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,30],"tags":[306],"class_list":["post-789","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-navody","category-wordpress","tag-pridani-nofollow"],"_links":{"self":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/789"}],"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=789"}],"version-history":[{"count":0,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/789\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media\/8624"}],"wp:attachment":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media?parent=789"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/categories?post=789"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/tags?post=789"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}