{"id":964,"date":"2025-03-24T14:28:08","date_gmt":"2025-03-24T14:28:08","guid":{"rendered":"https:\/\/wpgeodirectory.com\/documentation\/article\/how-to-use-geodirectory-conditional-tags\/"},"modified":"2025-04-03T15:24:29","modified_gmt":"2025-04-03T14:24:29","slug":"how-to-use-geodirectory-conditional-tags","status":"publish","type":"gd_place","link":"https:\/\/wpgeodirectory.com\/documentation\/article\/code-snippets\/how-to-use-geodirectory-conditional-tags\/","title":{"rendered":"How to use GeoDirectory Conditional Tags"},"content":{"rendered":"\n<p>You may want to show widgets only on certain pages and GeoDirectory produces a wide variety of &#8216;Conditional Tags&#8217; that can be used to turn a widget or block on or off. Interpreting and putting the Conditional Tag into action is done with custom code or a 3rd party plugin.<\/p>\n\n\n\n<p>New to Conditional Tags? Read more about them here: <a href=\"https:\/\/codex.wordpress.org\/Conditional_Tags\">https:\/\/codex.wordpress.org\/Conditional_Tags<\/a><\/p>\n\n\n\n<p>Common examples include:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">geodir_get_current_posttype()=='gd_place' - show if post type is gd_place\nis_singular( 'gd_place' ) - show if gd_place details page (single)\nis_post_type_archive('gd_place') - archive for gd_place\nis_tax( 'taxonomy-name', 'category-name' ) - specific category\nis_post_type_archive('gd_place') &amp;&amp; is_tax( 'taxonomy-name', 'category-name' ) - gd_place AND a specific category (BOTH)\nis_front_page() - is the WP front page\ngeodir_is_page( 'add-listing' ) - GD Add listing page\ngeodir_is_page( 'location' ) \u2013 Determines whether current page is location page.\ngeodir_location_get_current( 'location' )\t\u2013 Current location. Current Country or Region or City or Neighbourhood. Depends on current location type.\ngeodir_location_get_current( 'location_slug' ) \u2013 Current location. Current Country slug or Region slug or City slug or Neighbourhood slug. Depends on current location type.\ngeodir_location_get_current( 'id' )\t\u2013 Location id. Only if city is set.\ngeodir_location_get_current( 'type' )\t\u2013 Location type. One of from \"country, region, city, neighbourhood, me, gps\".\ngeodir_location_get_current( 'is_default' )\t\u2013 Is default location. Only if city is set.\ngeodir_location_get_current( 'country' )\t\u2013 Country name. Ex: United Kingdom.\ngeodir_location_get_current( 'country_slug' ) \u2013 Country slug. Ex: united-kingdom.\ngeodir_location_get_current( 'region' )\t\u2013 Region name. Ex: Greater London.\ngeodir_location_get_current( 'region_slug' )\t\u2013 Region slug. Ex: greater-london.\ngeodir_location_get_current( 'city' )\t\u2013 City name. Ex: London\ngeodir_location_get_current( 'city_slug' )\t\u2013 City slug. Ex: london.\ngeodir_location_get_current( 'neighbourhood' )\t\u2013 Neighbourhood name. Ex: Camden Town.\ngeodir_location_get_current( 'neighbourhood_slug' )\t\u2013 Neighbourhood slug. Ex: camden-town.\ngeodir_location_get_current( 'latitude' )\t\u2013 Latitude. Only if city or neighbourhood or gps\/me is set. Ex: 51.4587232758\ngeodir_location_get_current( 'longitude' )\t\u2013 Longitude. Only if city or neighbourhood or gps\/me is set. Ex: -0.1956555088\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>You may want to show widgets only on certain pages and GeoDirectory produces a wide variety of &#8216;Conditional Tags&#8217; that can be used to turn a widget or block on or off. Interpreting and putting the Conditional Tag into action is done with custom code or a 3rd party plugin. New to Conditional Tags? Read [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"article\/tags":[],"article\/categories":[211,432,433],"class_list":["post-964","gd_place","type-gd_place","status-publish","hentry","gd_placecategory-tips-tricks-more","gd_placecategory-how-tos","gd_placecategory-code-snippets"],"_links":{"self":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/964","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=964"}],"version-history":[{"count":0,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/964\/revisions"}],"wp:attachment":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/media?parent=964"}],"wp:term":[{"taxonomy":"gd_place_tags","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/tags?post=964"},{"taxonomy":"gd_placecategory","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/categories?post=964"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}