{"id":1024,"date":"2025-03-24T14:28:17","date_gmt":"2025-03-24T14:28:17","guid":{"rendered":"https:\/\/wpgeodirectory.com\/documentation\/article\/no-index-directives-on-all-or-some-gd-pages\/"},"modified":"2025-04-03T15:24:39","modified_gmt":"2025-04-03T14:24:39","slug":"no-index-directives-on-all-or-some-gd-pages","status":"publish","type":"gd_place","link":"https:\/\/wpgeodirectory.com\/documentation\/article\/tips-tricks-more\/no-index-directives-on-all-or-some-gd-pages\/","title":{"rendered":"No index directives on  all or some GD pages"},"content":{"rendered":"\n<p>Full Coonditional Method<\/p>\n\n\n\n<p>The code snippet below has 2 hooks:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>add noindex to all GD pages<\/li>\n\n\n\n<li>add noindex to some GD pages, with a comprehensive list of conditionals<\/li>\n<\/ol>\n\n\n\n<p>It should\u00a0work with most SEO plugins.<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-php\">\/**\n * Add noindex, nofollow robots meta directive on all GD pages.\n *\/\nadd_filter( &#039;wp_robots&#039;, &#039;gdsnippet_no_robots_all&#039;, 999, 1 );\nfunction gdsnippet_no_robots_all( $robot_directives ) {\n\n    if ( function_exists( &#039;geodir_is_geodir_page&#039; ) &amp;&amp; geodir_is_geodir_page() )\n    {\n        return &#091;\n            &#039;noindex&#039;   =&gt; true,\n            &#039;nofollow&#039;  =&gt; true,\n        &#093;;\n    }\n\n    return $robot_directives;\n}\n\n\/**\n * Add noindex, nofollow robots meta directive on some GD pages.\n *\/\nadd_filter( &#039;wp_robots&#039;, &#039;gdsnippet_no_robots_some&#039;, 999, 1 );\nfunction gdsnippet_no_robots_some( $robot_directives ) {\n\n    \/\/ Bail early if geodir_is_page() doesn&#039;t exists.\n    if ( ! function_exists( &#039;geodir_is_page&#039; ) ) {\n        return $robot_directives;\n    }\n\n    \/**\n     * Combine conditionals with &quot;||&quot; (OR) in-between.\n     * Ex: if ( geodir_is_page( &#039;single ) || geodir_is_page( &#039;archive ) ).\n     *\/\n\n    if (\n        \/\/ GD main pages.\n        geodir_is_page( &#039;search&#039; )\n        || geodir_is_page( &#039;archive&#039; ) \/\/ All archives.\n        || geodir_is_page( &#039;post_type&#039; ) \/\/ Same as above, doesn&#039;t include taxonomy archives.\n        || geodir_is_page( &#039;location&#039; )\n        || geodir_is_page( &#039;single&#039; )\n\n        \/\/ Add listing pages.\n        || geodir_is_page( &#039;add-listing&#039; ) \/\/ Includes edit-listing pages.\n        || geodir_is_page( &#039;edit-listing&#039; ) \/\/ Only edit-listing pages.\n        || geodir_is_page( &#039;listing-success&#039; )\n        || geodir_is_page( &#039;preview&#039; )\n\n        \/\/ Others.\n        || geodir_is_page( &#039;author&#039; )\n        || geodir_is_page( &#039;compare&#039; )\n    )\n\n    \/\/ If any of the above is true, return a no-index robots meta.\n    {\n        return &#091;\n            &#039;noindex&#039;   =&gt; true,\n            &#039;nofollow&#039;  =&gt; true,\n        &#093;;\n    }\n\n    \/\/ If not, don&#039;t interfere.\n    return $robot_directives;\n}<\/code><\/pre>\n\n\n\n<p><br>Short Snippet<\/p>\n\n\n\n<p>The following snippet will de-index all single listing pages.<br>It&#8217;s possible for your developer\u00a0to extend it to include others, like search, archives, etc.<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-php\">add_filter( &#039;wp_robots&#039;, &#039;gdsnippet_no_robots&#039;, 999, 1 );\nfunction gdsnippet_no_robots( $robot_directives ) {\n\n    if ( function_exists( &#039;geodir_is_page&#039; ) &amp;&amp; geodir_is_page( &#039;single&#039; ) )\n    {\n        return &#091;\n            &#039;noindex&#039;   =&gt; true,\n            &#039;nofollow&#039;  =&gt; true,\n        &#093;;\n    }\n\n    return $robot_directives;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Full Coonditional Method The code snippet below has 2 hooks: It should\u00a0work with most SEO plugins. Short Snippet The following snippet will de-index all single listing pages.It&#8217;s possible for your developer\u00a0to extend it to include others, like search, archives, etc.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"article\/tags":[],"article\/categories":[211,2],"class_list":["post-1024","gd_place","type-gd_place","status-publish","hentry","gd_placecategory-tips-tricks-more","gd_placecategory-uncategorized"],"_links":{"self":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/1024","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=1024"}],"version-history":[{"count":0,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/1024\/revisions"}],"wp:attachment":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/media?parent=1024"}],"wp:term":[{"taxonomy":"gd_place_tags","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/tags?post=1024"},{"taxonomy":"gd_placecategory","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/categories?post=1024"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}