{"id":232767,"date":"2023-01-28T12:28:00","date_gmt":"2023-01-28T09:28:00","guid":{"rendered":"https:\/\/wordpress.mediadoma.com\/?p=232767"},"modified":"2022-11-10T17:41:01","modified_gmt":"2022-11-10T14:41:01","slug":"como-mostrar-links-apenas-em-paginas-iniciais-de-blogs-do-wordpress","status":"publish","type":"post","link":"https:\/\/wordpress.mediadoma.com\/pt-pt\/como-mostrar-links-apenas-em-paginas-iniciais-de-blogs-do-wordpress\/","title":{"rendered":"Como mostrar links apenas em p\u00e1ginas iniciais de blogs do WordPress?"},"content":{"rendered":"<p>\u00c0s vezes voc\u00ea s\u00f3 quer mostrar alguns links na p\u00e1gina inicial do blog, mas n\u00e3o em outras p\u00e1ginas, ent\u00e3o o seguinte truque \u00e9 \u00fatil.<\/p>\n<p>Em primeiro lugar, voc\u00ea pode decidir onde colocar os links, usando widgets do WordPress (Apar\u00eancia -&gt; Wigets -&gt; Texto\/HTML) ou pode editar o arquivo de modelo <strong>footer.php<\/strong>.<\/p>\n<p>Ent\u00e3o, usando o c\u00f3digo Javascript apresentado abaixo, podemos verificar a URL atual e decidir se deseja imprimir os hiperlinks ou n\u00e3o.<\/p>\n<p>Podemos usar <strong>document.URL<\/strong> ou <strong>windows.location<\/strong> para obter a URL atual da p\u00e1gina. Voc\u00ea pode verificar se o comprimento da URL \u00e9 m\u00ednimo, por exemplo, <a href=\"https:\/\/helloacm.com\/\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">https:\/\/helloacm.com\/<\/a> (21 caracteres) ou <a href=\"https:\/\/helloacm.com\/\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">http:\/\/helloacm.com\/<\/a> (20 caracteres). Portanto, se o comprimento do URL for inferior a 20 caracteres, ele estar\u00e1 na p\u00e1gina inicial.<\/p>\n<pre><code>&lt;script&gt;\nvar cururl = window.location.toString();\nif (cururl.length &lt;= 20) {\n\u00a0 document.write(\"&lt;a class=\"vglnk\" target=\"_blank\" href=\"http:\/\/helloacm.com\" rel=\"nofollow\"&gt;&lt;span&gt;http&lt;\/span&gt;&lt;span&gt;:\/\/&lt;\/span&gt;&lt;span&gt;helloacm&lt;\/span&gt;&lt;span&gt;.&lt;\/span&gt;&lt;span&gt;com&lt;\/span&gt;&lt;\/a&gt;\");\n}\n&lt;\/script&gt;<\/code><\/pre>\n<p>Alternativamente, voc\u00ea pode facilitar a leitura.<\/p>\n<pre><code>&lt;script&gt;\nvar cururl = window.location.toString().toUpperCase();\nif ((cururl == '&lt;a class=\"vglnk\" target=\"_blank\" href=\"HTTP:\/\/HELLOACM.COM\/\" rel=\"nofollow\"&gt;&lt;span&gt;HTTP&lt;\/span&gt;&lt;span&gt;:\/\/&lt;\/span&gt;&lt;span&gt;HELLOACM&lt;\/span&gt;&lt;span&gt;.&lt;\/span&gt;&lt;span&gt;COM&lt;\/span&gt;&lt;span&gt;\/&lt;\/span&gt;&lt;\/a&gt;') || (cururl == '&lt;a class=\"vglnk\" target=\"_blank\" href=\"HTTPS:\/\/HELLOACM.COM\/\" rel=\"nofollow\"&gt;&lt;span&gt;HTTPS&lt;\/span&gt;&lt;span&gt;:\/\/&lt;\/span&gt;&lt;span&gt;HELLOACM&lt;\/span&gt;&lt;span&gt;.&lt;\/span&gt;&lt;span&gt;COM&lt;\/span&gt;&lt;span&gt;\/&lt;\/span&gt;&lt;\/a&gt;')) {\n\u00a0 document.write(\"&lt;a class=\"vglnk\" target=\"_blank\" href=\"http:\/\/helloacm.com\" rel=\"nofollow\"&gt;&lt;span&gt;http&lt;\/span&gt;&lt;span&gt;:\/\/&lt;\/span&gt;&lt;span&gt;helloacm&lt;\/span&gt;&lt;span&gt;.&lt;\/span&gt;&lt;span&gt;com&lt;\/span&gt;&lt;\/a&gt;\");\n}\n&lt;\/script&gt;<\/code><\/pre>\n<p>Agora, o link s\u00f3 ser\u00e1 impresso quando estiver na p\u00e1gina inicial. A maioria dos bots de mecanismos de busca modernos saber\u00e3o como rastrear o c\u00f3digo Javascript, ent\u00e3o eles seguir\u00e3o os links (gerados por Javascript) sem problemas. Portanto, n\u00e3o deixe que o SEO o impe\u00e7a de fazer isso.<\/p>\n<p><div id=\"PostUnique_PostSource\" style=\"padding-top: 50px\">Fonte de grava\u00e7\u00e3o:  <a target=\"_blank\" rel=\"noopener nofollow\" href=\"\/\/helloacm.com\" class=\"external external_icon\">helloacm.com<\/a><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Como mostrar links apenas nas p\u00e1ginas iniciais dos blogs do WordPress?<\/p>\n","protected":false},"author":1,"featured_media":223984,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_wp_rev_ctl_limit":""},"categories":[898,806,846,867],"tags":[1170],"class_list":["post-232767","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-codigo-2","category-php-8","category-tutoriais","category-wordpress-8","tag-affiai-pt-pt"],"_links":{"self":[{"href":"https:\/\/wordpress.mediadoma.com\/pt-pt\/wp-json\/wp\/v2\/posts\/232767","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.mediadoma.com\/pt-pt\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.mediadoma.com\/pt-pt\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/pt-pt\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/pt-pt\/wp-json\/wp\/v2\/comments?post=232767"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.mediadoma.com\/pt-pt\/wp-json\/wp\/v2\/posts\/232767\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/pt-pt\/wp-json\/wp\/v2\/media\/223984"}],"wp:attachment":[{"href":"https:\/\/wordpress.mediadoma.com\/pt-pt\/wp-json\/wp\/v2\/media?parent=232767"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/pt-pt\/wp-json\/wp\/v2\/categories?post=232767"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/pt-pt\/wp-json\/wp\/v2\/tags?post=232767"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}