{"id":91,"date":"2018-07-19T04:41:28","date_gmt":"2018-07-19T04:41:28","guid":{"rendered":"http:\/\/www.projectimmerse.com\/?p=91"},"modified":"2020-06-16T23:51:48","modified_gmt":"2020-06-16T23:51:48","slug":"wordpress-links-with-hashes-and-disabling-a-links-normal-behavior","status":"publish","type":"post","link":"https:\/\/www.projectimmerse.com\/blog\/wordpress-links-with-hashes-and-disabling-a-links-normal-behavior\/","title":{"rendered":"WordPress links with hashes and disabling a links normal behavior"},"content":{"rendered":"<p>WordPress allows for the creation of custom links within the Menu&#8217;s area. I like this feature, it has been around for years. <\/p>\n<p>I use it sometimes to create internal and external links but there are cases where I wanted them disabled. In this case and as you may have experienced &#8211; a custom link requires a value. It&#8217;s pretty common to just put a hash &#8220;#&#8221; as a value. <\/p>\n<p>Something like href=&#8221;#&#8221;. This however will cause the element to behave normally as it should &#8211; there&#8217;s nothing wrong with that except it will cause your page to &#8220;jump&#8221; back up to the top of the page which can be annoying for visitors. <\/p>\n<p><!--more--><\/p>\n<p>Below a snippet solution to take care of this. Jquery is still awesome, the $ sign is still awesome, despite the new kids on the block &#8211; vue.js, angular and friends. <\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\r\n&lt;script&gt;\r\n$(document).ready(function(){\r\n\r\n\u00a0 \u00a0$('#menu-top-nav li a&#x5B;href^=&quot;#&quot;]').click(function(e){\r\n\u00a0 \u00a0 \u00a0 e.preventDefault();\r\n\u00a0 \u00a0});\r\n\r\n});\r\n&lt;\/script&gt;\r\n\r\n<\/pre>\n<p>We target the menu element and access any link containing hash. We pass the event object (a global environment object) and run it&#8217;s method preventDefault() to prevent the link from behaving like a link. And voila &#8211; done and done. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>WordPress allows for the creation of custom links within the Menu&#8217;s area. I like this feature, it has been around for years. I use it sometimes to create internal and external links but there are cases where I wanted them disabled. In this case and as you may have experienced &#8211; a custom link requires &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.projectimmerse.com\/blog\/wordpress-links-with-hashes-and-disabling-a-links-normal-behavior\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;WordPress links with hashes and disabling a links normal behavior&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-91","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Wordpress links with hashes and disabling a links normal behavior - Project Immerse<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.projectimmerse.com\/blog\/wordpress-links-with-hashes-and-disabling-a-links-normal-behavior\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Wordpress links with hashes and disabling a links normal behavior - Project Immerse\" \/>\n<meta property=\"og:description\" content=\"WordPress allows for the creation of custom links within the Menu&#8217;s area. I like this feature, it has been around for years. I use it sometimes to create internal and external links but there are cases where I wanted them disabled. In this case and as you may have experienced &#8211; a custom link requires &hellip; Continue reading &quot;WordPress links with hashes and disabling a links normal behavior&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.projectimmerse.com\/blog\/wordpress-links-with-hashes-and-disabling-a-links-normal-behavior\/\" \/>\n<meta property=\"og:site_name\" content=\"Project Immerse\" \/>\n<meta property=\"article:published_time\" content=\"2018-07-19T04:41:28+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-06-16T23:51:48+00:00\" \/>\n<meta name=\"author\" content=\"projectimmerse\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"projectimmerse\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wordpress-links-with-hashes-and-disabling-a-links-normal-behavior\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wordpress-links-with-hashes-and-disabling-a-links-normal-behavior\\\/\"},\"author\":{\"name\":\"projectimmerse\",\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/#\\\/schema\\\/person\\\/c53f2864be524ee6fa08a7e4800dd1e5\"},\"headline\":\"WordPress links with hashes and disabling a links normal behavior\",\"datePublished\":\"2018-07-19T04:41:28+00:00\",\"dateModified\":\"2020-06-16T23:51:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wordpress-links-with-hashes-and-disabling-a-links-normal-behavior\\\/\"},\"wordCount\":218,\"commentCount\":0,\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wordpress-links-with-hashes-and-disabling-a-links-normal-behavior\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wordpress-links-with-hashes-and-disabling-a-links-normal-behavior\\\/\",\"url\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wordpress-links-with-hashes-and-disabling-a-links-normal-behavior\\\/\",\"name\":\"Wordpress links with hashes and disabling a links normal behavior - Project Immerse\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/#website\"},\"datePublished\":\"2018-07-19T04:41:28+00:00\",\"dateModified\":\"2020-06-16T23:51:48+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/#\\\/schema\\\/person\\\/c53f2864be524ee6fa08a7e4800dd1e5\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wordpress-links-with-hashes-and-disabling-a-links-normal-behavior\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wordpress-links-with-hashes-and-disabling-a-links-normal-behavior\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wordpress-links-with-hashes-and-disabling-a-links-normal-behavior\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"WordPress links with hashes and disabling a links normal behavior\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/\",\"name\":\"Project Immerse\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/#\\\/schema\\\/person\\\/c53f2864be524ee6fa08a7e4800dd1e5\",\"name\":\"projectimmerse\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d06955033d6227bfdcf30014e457e4334f7deeb73907de49b65ec2484921931?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d06955033d6227bfdcf30014e457e4334f7deeb73907de49b65ec2484921931?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d06955033d6227bfdcf30014e457e4334f7deeb73907de49b65ec2484921931?s=96&d=mm&r=g\",\"caption\":\"projectimmerse\"},\"url\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/author\\\/projectimmerse\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Wordpress links with hashes and disabling a links normal behavior - Project Immerse","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.projectimmerse.com\/blog\/wordpress-links-with-hashes-and-disabling-a-links-normal-behavior\/","og_locale":"en_US","og_type":"article","og_title":"Wordpress links with hashes and disabling a links normal behavior - Project Immerse","og_description":"WordPress allows for the creation of custom links within the Menu&#8217;s area. I like this feature, it has been around for years. I use it sometimes to create internal and external links but there are cases where I wanted them disabled. In this case and as you may have experienced &#8211; a custom link requires &hellip; Continue reading \"WordPress links with hashes and disabling a links normal behavior\"","og_url":"https:\/\/www.projectimmerse.com\/blog\/wordpress-links-with-hashes-and-disabling-a-links-normal-behavior\/","og_site_name":"Project Immerse","article_published_time":"2018-07-19T04:41:28+00:00","article_modified_time":"2020-06-16T23:51:48+00:00","author":"projectimmerse","twitter_card":"summary_large_image","twitter_misc":{"Written by":"projectimmerse","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.projectimmerse.com\/blog\/wordpress-links-with-hashes-and-disabling-a-links-normal-behavior\/#article","isPartOf":{"@id":"https:\/\/www.projectimmerse.com\/blog\/wordpress-links-with-hashes-and-disabling-a-links-normal-behavior\/"},"author":{"name":"projectimmerse","@id":"https:\/\/www.projectimmerse.com\/blog\/#\/schema\/person\/c53f2864be524ee6fa08a7e4800dd1e5"},"headline":"WordPress links with hashes and disabling a links normal behavior","datePublished":"2018-07-19T04:41:28+00:00","dateModified":"2020-06-16T23:51:48+00:00","mainEntityOfPage":{"@id":"https:\/\/www.projectimmerse.com\/blog\/wordpress-links-with-hashes-and-disabling-a-links-normal-behavior\/"},"wordCount":218,"commentCount":0,"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.projectimmerse.com\/blog\/wordpress-links-with-hashes-and-disabling-a-links-normal-behavior\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.projectimmerse.com\/blog\/wordpress-links-with-hashes-and-disabling-a-links-normal-behavior\/","url":"https:\/\/www.projectimmerse.com\/blog\/wordpress-links-with-hashes-and-disabling-a-links-normal-behavior\/","name":"Wordpress links with hashes and disabling a links normal behavior - Project Immerse","isPartOf":{"@id":"https:\/\/www.projectimmerse.com\/blog\/#website"},"datePublished":"2018-07-19T04:41:28+00:00","dateModified":"2020-06-16T23:51:48+00:00","author":{"@id":"https:\/\/www.projectimmerse.com\/blog\/#\/schema\/person\/c53f2864be524ee6fa08a7e4800dd1e5"},"breadcrumb":{"@id":"https:\/\/www.projectimmerse.com\/blog\/wordpress-links-with-hashes-and-disabling-a-links-normal-behavior\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.projectimmerse.com\/blog\/wordpress-links-with-hashes-and-disabling-a-links-normal-behavior\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.projectimmerse.com\/blog\/wordpress-links-with-hashes-and-disabling-a-links-normal-behavior\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.projectimmerse.com\/blog\/"},{"@type":"ListItem","position":2,"name":"WordPress links with hashes and disabling a links normal behavior"}]},{"@type":"WebSite","@id":"https:\/\/www.projectimmerse.com\/blog\/#website","url":"https:\/\/www.projectimmerse.com\/blog\/","name":"Project Immerse","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.projectimmerse.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.projectimmerse.com\/blog\/#\/schema\/person\/c53f2864be524ee6fa08a7e4800dd1e5","name":"projectimmerse","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4d06955033d6227bfdcf30014e457e4334f7deeb73907de49b65ec2484921931?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4d06955033d6227bfdcf30014e457e4334f7deeb73907de49b65ec2484921931?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4d06955033d6227bfdcf30014e457e4334f7deeb73907de49b65ec2484921931?s=96&d=mm&r=g","caption":"projectimmerse"},"url":"https:\/\/www.projectimmerse.com\/blog\/author\/projectimmerse\/"}]}},"_links":{"self":[{"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/posts\/91","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/comments?post=91"}],"version-history":[{"count":3,"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/posts\/91\/revisions"}],"predecessor-version":[{"id":469,"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/posts\/91\/revisions\/469"}],"wp:attachment":[{"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/media?parent=91"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/categories?post=91"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/tags?post=91"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}