{"id":233195,"date":"2023-02-06T15:48:00","date_gmt":"2023-02-06T12:48:00","guid":{"rendered":"https:\/\/wordpress.mediadoma.com\/?p=233195"},"modified":"2022-11-10T19:50:15","modified_gmt":"2022-11-10T16:50:15","slug":"come-aggiungere-automaticamente-un-url-di-condivisione-alla-fine-di-ogni-post-e-pagina-per-wordpress","status":"publish","type":"post","link":"https:\/\/wordpress.mediadoma.com\/it\/come-aggiungere-automaticamente-un-url-di-condivisione-alla-fine-di-ogni-post-e-pagina-per-wordpress\/","title":{"rendered":"Come aggiungere automaticamente un URL di condivisione alla fine di ogni post e pagina per WordPress?"},"content":{"rendered":"<p>A volte ho bisogno di copiare i post da qualche parte per una facile condivisione e alla fine del post, indicher\u00f2 l&#8217;URL dell&#8217;articolo originale. E lo trovo non cos\u00ec conveniente in quanto devo copiare manualmente l&#8217;URL e incollarlo. Il seguente trucco pu\u00f2 risolvere facilmente questo problema. Alla fine di ogni post\/pagine verr\u00e0 aggiunto il link alla pagina corrente.<\/p>\n<p>Modifica il file modello <strong>functions.php<\/strong> e aggiungi il seguente codice PHP alla fine del file.<\/p>\n<pre><code>\/\/ &lt;a class=\"vglnk\" target=\"_blank\" href=\"http:\/\/helloacm.com\" rel=\"nofollow\"&gt;&lt;span&gt;helloacm&lt;\/span&gt;&lt;span&gt;.&lt;\/span&gt;&lt;span&gt;com&lt;\/span&gt;&lt;\/a&gt;\nadd_filter( 'the_content', 'insert_post' );\n\u00a0\nfunction insert_post( $content) {\n\u00a0 \u00a0 $post_id = get_the_ID();\n\u00a0 \u00a0 $link = get_permalink($post_id);\n\u00a0 \u00a0 $title = get_the_title($post_id);\n\u00a0 \u00a0 return $content.'&lt;BR\/&gt;Share this URL\uff1a&lt;a title=\"'.$title.'\" href=\"'.$link.'\"&gt;&lt;B&gt;'.$link.'&lt;\/B&gt;&lt;\/a&gt;';\n}<\/code><\/pre>\n<p>\u00c8 molto semplice e se conosci l&#8217;inglese capisci cosa significa. Il wordpress \u00e8 cos\u00ec potente perch\u00e9 fornisce gi\u00e0 tante utili funzioni come <strong>get_the_ID()<\/strong> che ottiene l&#8217;ID della pagina\/post corrente, <strong>get_permalink()<\/strong> che restituisce l&#8217;URL della pagina\/dei post, e <strong>get_the_title()<\/strong> ottiene il titolo di le pagine\/post. Queste due funzioni hanno il parametro opzionale [post id] che, se omesso, restituir\u00e0 la pagina\/i post correnti.<\/p>\n<p><div id=\"PostUnique_PostSource\" style=\"padding-top: 50px\">Fonte di registrazione:  <a target=\"_blank\" rel=\"noopener nofollow\" href=\"\/\/helloacm.com\" class=\"external external_icon\">helloacm.com<\/a><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Come aggiungere automaticamente un URL di condivisione alla fine di ogni post e pagina per WordPress?<\/p>\n","protected":false},"author":1,"featured_media":223973,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_wp_rev_ctl_limit":""},"categories":[918,896,835,720,844,865],"tags":[1168],"class_list":["post-233195","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-altro","category-codice","category-guida-per-principianti","category-sviluppatore","category-tutorial","category-wordpress-6","tag-affiai-it"],"_links":{"self":[{"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/posts\/233195","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/comments?post=233195"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/posts\/233195\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/media\/223973"}],"wp:attachment":[{"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/media?parent=233195"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/categories?post=233195"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/tags?post=233195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}