{"id":2852,"date":"2016-04-19T13:43:59","date_gmt":"2016-04-19T13:43:59","guid":{"rendered":"http:\/\/musilda.cz\/?p=2852"},"modified":"2016-04-19T13:43:59","modified_gmt":"2016-04-19T13:43:59","slug":"provazani-obsahu-pomoci-pluginu-posts-2-posts","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/provazani-obsahu-pomoci-pluginu-posts-2-posts\/","title":{"rendered":"Prov\u00e1z\u00e1n\u00ed obsahu pomoc\u00ed pluginu Posts 2 Posts"},"content":{"rendered":"\n

Vazby mezi obsahem, prolinkov\u00e1n\u00ed, souvisej\u00edc\u00ed p\u0159\u00edsp\u011bvky, nazv\u011bte to jak budete cht\u00edt, jsou \u010dasto zmi\u0148ovan\u00fdm zp\u016fsobem, jak nab\u00eddnout \u010dten\u00e1\u0159i podobn\u00fd zaj\u00edmav\u00fd obsah. Z\u00e1rove\u0148 tato technika p\u0159isp\u00edv\u00e1, k lep\u0161\u00edm v\u00fdsledk\u016fm ve vyhled\u00e1v\u00e1n\u00ed. Zde nebudu toto stanovisko obhajovat, nejsem specialista na SEO, ale na mnoha m\u00edstech se zmi\u0148uje pozitivn\u00ed dopad, propojen\u00ed obsahu.<\/p>\n\n\n\n

Existuj\u00ed r\u016fzn\u00e9 „Souvisej\u00edc\u00ed p\u0159\u00edsp\u011bvky“ pluginy, v des\u00edtk\u00e1ch variant, ale tyto pluginy, nar\u00e1\u017e\u00ed na sv\u00e9 hranice, p\u0159i pou\u017eit\u00ed r\u016fzn\u00fdch druh\u016f obsahu. Jednodu\u0161e, p\u0159\u00edsp\u011bvky, na str\u00e1nce s nimi nezobraz\u00edte.<\/p>\n\n\n\n

Na\u0161t\u011bst\u00ed, existuje plugin Posts 2 Posts, kter\u00fd vytvo\u0159il Scribu, jm\u00e9no, kter\u00e9 nen\u00ed nezn\u00e1m\u00e9, v\u0161em, kdo se kolem WordPressu pohybuj\u00ed. Dlouhou dobu byl jedn\u00edm z v\u00fdvoj\u00e1\u0159\u016f WP CLI rozhran\u00ed. O kvalit\u00e1ch pluginu mluv\u00ed i to, \u017ee s p\u0159\u00edpravou nov\u00e9 verze WordPressu, se v\u017edy objev\u00ed diskuze o za\u0159azen\u00ed pluginu do j\u00e1dra.<\/p>\n\n\n\n

Co tedy Posts 2 Posts dok\u00e1\u017ee?<\/strong><\/p>\n\n\n\n

Zjednodu\u0161en\u011b \u0159e\u010deno, prov\u00e1\u017ee r\u016fzn\u00e9 druhy obsahu. \u010cl\u00e1nky se str\u00e1nkou, custom post type s custom post type, jak jen budete cht\u00edt.<\/p>\n\n\n\n

P\u0159\u00edklad:<\/strong><\/p>\n\n\n\n

Budete m\u00edt custom post type Projekt a \u010dl\u00e1nky, kter\u00e9 se budou t\u00fdkat pr\u00e1v\u011b uskute\u010dn\u011bn\u00fdch projekt\u016f. Vytvo\u0159\u00edte si spojen\u00ed, mezi Projekt a \u010dl\u00e1nky a pak ji\u017e jen budete vyb\u00edrat, kter\u00e9 \u010dl\u00e1nky se k projektu p\u0159i\u0159ad\u00ed. Naprosto ide\u00e1ln\u00ed po n\u00e1v\u0161t\u011bvn\u00edka a pro SEO.<\/p>\n\n\n\n

Bohu\u017eel, plugin nepat\u0159\u00ed mezi ty, kter\u00e9 nainstalujete a m\u016f\u017eete jen klikat. Propojen\u00ed mus\u00edte vytv\u00e1\u0159et.<\/p>\n\n\n\n

Na za\u010d\u00e1tek si uk\u00e1\u017eeme propojen\u00ed str\u00e1nky a \u010dl\u00e1nk\u016f. Do functions.php vlo\u017e\u00edte tento k\u00f3d:<\/p>\n\n\n\n

function my_connection_types() {\n p2p_register_connection_type( array(\n 'name' => 'posts_to_pages',\n 'from' => 'post',\n 'to' => 'page'\n ) );\n }\n add_action( 'p2p_init', 'my_connection_types' );<\/pre>\n\n\n\n

Vytvo\u0159ili jste tak propojen\u00ed \u010dl\u00e1nk\u016f a str\u00e1nek. V detailu str\u00e1nky pak uvid\u00edte nov\u00fd metabox:<\/p>\n\n\n

\n
\"posts2posts\"<\/a><\/figure><\/div>\n\n\n

Vyberete p\u0159\u00edslu\u0161n\u00e9 \u010dl\u00e1nky a metabox se postar\u00e1 o ulo\u017een\u00ed.<\/p>\n\n\n

\n
\"\"<\/figure><\/div>\n\n\n

N\u00e1sledn\u011b si mus\u00edme vytvo\u0159it funkci, pro vypisov\u00e1n\u00ed odkaz\u016f na \u010dl\u00e1nky a vlo\u017eit ji do functions.php<\/p>\n\n\n\n

function custom_list_related($post_id, $title = ''){\n\n$query_args = array(\n 'connected_type' => 'posts_to_pages',\n 'connected_items' => intval($post_id),\n 'nopaging' => true\n );\n\n$query = new WP_Query($query_args);\n\nif($query->have_posts()):\n\nif(empty($title))\n $title = __('\u010cl\u00e1nky', 'frl');\n ?>\n <h3><?php echo $title; ?><\/h3>\n <ul class=\"related-items\">\n\n<?php while($query->have_posts()): $query->the_post(); ?>\n <li><a href=\"<?php the_permalink();?>\"><?php the_title();?><\/a><\/li>\n <?php endwhile;?>\n\n<\/ul>\n <?php\n endif;\n wp_reset_postdata();\n }<\/pre>\n\n\n\n

Jako posledn\u00ed krok, mus\u00edme vlo\u017eit funkci , do souboru \u0161ablony, nap\u0159\u00edklad page.php:<\/p>\n\n\n\n

global $post;\n custom_list_related($post->ID);<\/pre>\n\n\n\n

V\u00fdsledek vypad\u00e1 takto:<\/p>\n\n\n

\n
\"\"<\/figure><\/div>\n\n\n

Jak m\u016f\u017eete vid\u011bt, na str\u00e1nce se zobrazuj\u00ed t\u0159i odkazy p\u0159i\u0159azen\u00fdch \u010dl\u00e1nk\u016f.<\/p>\n\n\n\n

V p\u0159\u00edpad\u011b, \u017ee nechcete vkl\u00e1dat funkce do \u0161ablony, tak m\u016f\u017eete pou\u017e\u00edt shortcody:<\/p>\n\n\n\n

[p2p_connected type=posts_to_pages]\n<\/pre>\n\n\n

[p2p_related type=posts_to_pages mode=ol]<\/p>\n\n\n\n

Pro \u00fapravu shortcod\u016f, m\u00e1 plugin vlo\u017een\u00e9 akce a filtry https:\/\/github.com\/scribu\/wp-posts-to-posts\/wiki\/Actions-and-filters<\/a><\/p>\n\n\n\n

Ostatn\u011b, cel\u00e1 Wiki na GitHubu je velmi rozs\u00e1hl\u00e1 a obsahuje \u0159adu uk\u00e1zek.<\/p>\n\n\n\n

Mo\u017en\u00e1 si \u0159\u00edk\u00e1te, \u017ee na takov\u00e9m pluginu nic moc nen\u00ed, ale dejte tento \u010dl\u00e1nek p\u0159e\u010d\u00edst tomu, kdo se v\u00e1m star\u00e1 o SEO, nebo obsahovou strategii a garantuji v\u00e1m, \u017ee z mo\u017enost\u00ed kter\u00e9 se nab\u00edz\u00ed, bude nad\u0161en. Jen nam\u00e1tkou – m\u016f\u017eete vytv\u00e1\u0159et seri\u00e1ly \u010dl\u00e1nk\u016f, propojit automobily s dealery a dal\u0161\u00ed a dal\u0161\u00ed zp\u016fsoby.<\/p>\n\n\n\n

Zkr\u00e1tka, pro rozs\u00e1hlej\u0161\u00ed obsahov\u00e9 weby, naprosto ide\u00e1ln\u00ed z\u00e1le\u017eitost.<\/p>\n\n\n\n

Plugin st\u00e1hnete zde.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"

Vazby mezi obsahem, prolinkov\u00e1n\u00ed, souvisej\u00edc\u00ed p\u0159\u00edsp\u011bvky, nazv\u011bte to jak budete cht\u00edt, jsou \u010dasto zmi\u0148ovan\u00fdm zp\u016fsobem, jak nab\u00eddnout \u010dten\u00e1\u0159i podobn\u00fd zaj\u00edmav\u00fd obsah. Z\u00e1rove\u0148 tato technika p\u0159isp\u00edv\u00e1, k lep\u0161\u00edm v\u00fdsledk\u016fm ve vyhled\u00e1v\u00e1n\u00ed. Zde nebudu toto stanovisko obhajovat, nejsem specialista na SEO, ale na mnoha m\u00edstech se zmi\u0148uje pozitivn\u00ed dopad, propojen\u00ed obsahu. Existuj\u00ed r\u016fzn\u00e9 „Souvisej\u00edc\u00ed p\u0159\u00edsp\u011bvky“ pluginy, v<\/p>\n","protected":false},"author":1,"featured_media":2856,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[298,311,359],"class_list":["post-2852","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress-pluginy","tag-posts-2-posts","tag-prolinkovani-wordpress","tag-souvisejici-prispevky"],"_links":{"self":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/2852"}],"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=2852"}],"version-history":[{"count":0,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/2852\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media\/2856"}],"wp:attachment":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media?parent=2852"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/categories?post=2852"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/tags?post=2852"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}