{"id":991,"date":"2025-03-24T14:28:13","date_gmt":"2025-03-24T14:28:13","guid":{"rendered":"https:\/\/wpgeodirectory.com\/documentation\/article\/how-to-restrict-tags-to-existing-tags-only\/"},"modified":"2025-04-03T15:24:34","modified_gmt":"2025-04-03T14:24:34","slug":"how-to-restrict-tags-to-existing-tags-only","status":"publish","type":"gd_place","link":"https:\/\/wpgeodirectory.com\/documentation\/article\/code-snippets\/how-to-restrict-tags-to-existing-tags-only\/","title":{"rendered":"How to restrict tags to existing tags only"},"content":{"rendered":"\n<p>To <strong>only allow existing tags<\/strong> to be selected as part of listing submissions, use this code snippet:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-php\">function gd_snippet_210726_disable_new_tags( $html, $cf ) {\n\t$html = str_replace( &#039;data-tags=&quot;true&quot;&#039;, &#039;&#039;, $html );\n\t$html = str_replace( &#039;id=&quot;post_tags&quot;&#039;, &#039;id=&quot;post_tags&quot; data-tags=&quot;false&quot;&#039;, $html );\n\n\treturn $html;\n}\nadd_filter( &#039;geodir_custom_field_input_tags&#039;, &#039;gd_snippet_210726_disable_new_tags&#039;, 999, 2 );<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-blockstrap-blockstrap-widget-alert d-flex align-items-center fade show alert alert-info mb-3\" role=\"alert\"><span class=\"fas fa-info-circle me-2\"><\/span><span class=\"flex-grow-1\">We recommend using the <a href=\"https:\/\/wpgeodirectory.com\/documentation\/article\/useful-plugins\/code-snippets-plugin\/\">Code Snippets<\/a> plugin to add snippets to your site.&nbsp;<\/span><\/div>\n","protected":false},"excerpt":{"rendered":"<p>To only allow existing tags to be selected as part of listing submissions, use this code snippet:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"article\/tags":[],"article\/categories":[211,433],"class_list":["post-991","gd_place","type-gd_place","status-publish","hentry","gd_placecategory-tips-tricks-more","gd_placecategory-code-snippets"],"_links":{"self":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/991","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article"}],"about":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/types\/gd_place"}],"author":[{"embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/comments?post=991"}],"version-history":[{"count":0,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/991\/revisions"}],"wp:attachment":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/media?parent=991"}],"wp:term":[{"taxonomy":"gd_place_tags","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/tags?post=991"},{"taxonomy":"gd_placecategory","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/categories?post=991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}