{"id":164,"date":"2018-07-21T07:39:42","date_gmt":"2018-07-21T07:39:42","guid":{"rendered":"https:\/\/wpgeodirectory.com\/docs-v2\/reference\/customizing-templates\/"},"modified":"2020-02-19T06:10:33","modified_gmt":"2020-02-19T06:10:33","slug":"customizing","status":"publish","type":"docs","link":"https:\/\/wpgeodirectory.com\/docs-v2\/faq\/customizing\/","title":{"rendered":"Customizing GeoDirectory"},"content":{"rendered":"<p><span class='bookmark-index'><br \/>\n<a href=\"#intro\">Introduction<\/a><br \/>\n<a href=\"#faq\">Frequently Asked Questions<\/a><br \/>\n<\/span><\/p>\n<h3><a name=\"intro\" href=\"#intro\">Introduction<\/a><\/h3>\n<p>We hope you find most options for personalizing GeoDirectory suitable for your needs. Personalizing means using GeoDirectory&#8217;s built in options for <a href=\"https:\/\/wpgeodirectory.com\/docs-v2\/geodirectory\/places\/tabs\/\">managing tabs<\/a> or <a href=\"https:\/\/wpgeodirectory.com\/docs-v2\/geodirectory\/page-design\/\">page design<\/a> to place or arrange any of the GD page <a href=\"https:\/\/wpgeodirectory.com\/docs-v2\/geodirectory\/design-elements\/\">elements<\/a>.<\/p>\n<p>However, if you want to go further and customize GeoDIrectory, then this page is for you. Maybe you are a developer and want to override plugin features, or build your own custom features or templates with PHP and CSS, then this page is for you. While <a href=\"https:\/\/wpgeodirectory.com\/support-policy\/\" rel=\"noopener noreferrer\" target=\"_blank\">we don&#8217;t provide support for customization<\/a>, we do want to encourage your customizing GeoDirectory (without making changes to core!) because we do like to see you make GeoDirectory your own. <\/p>\n<h4><a name=\"custom-code\" href=\"#custom-code\">Adding Custom Code<\/a><\/h4>\n<p><strong>CSS<\/strong><\/p>\n<p>We recommend that you add custom CSS code to the WordPress Customizer. You can find the &#8220;Additional CSS&#8221; option at:<\/p>\n<p><strong><em>WordPress &#8211; Appearance &#8211; Customizer &#8211; Additional CSS<\/em><\/strong><\/p>\n<p><strong>PHP<\/strong><\/p>\n<p>We recommend that, if possible, instead of adding your new PHP functions in your theme that you use the Code Snippets plugin instead. This is especially useful for GD themes that are updated regularly, because updates will overwrite any changes that have been made to the theme files. Find the <a href=\"https:\/\/wordpress.org\/plugins\/code-snippets\/\" rel=\"noopener noreferrer\" target=\"_blank\">Code Snippets plugin here<\/a>.<\/p>\n<h4><a name=\"templates\" href=\"#templates\">Templates<\/a><\/h4>\n<p>GeoDirectory uses a number of special templates to create the pages that make up the directory.<\/p>\n<p>Default templates can be found at <\/p>\n<pre><code class='css'>\/wp-content\/plugins\/geodirectory\/templates<\/code><\/pre>\n<p>The preferred method for customizing GeoDirectory is through the use of hooks and filters. GeoDirectory comes with many hooks and filters that can provide lots of customization options without the need for working with templates. However, if you are determined to work with the templates, then, just follow these steps:<\/p>\n<p>The default templates are located in the plugin folder <\/p>\n<pre><code class='css'>\/wp-content\/plugins\/geodirectory\/templates<\/code><\/pre>\n<p>Navigate to the folder for your active child theme.<br \/>\nCreate a new sub-folder called geodirectory.<br \/>\nExample of the new sub-folder for a child theme called &#8216;mycildtheme&#8217;<\/p>\n<pre><code class='css'>\/wp-content\/themes\/mychildtheme\/geodirectory\/<\/code><\/pre>\n<h4>Template Overrides<\/h4>\n<p>In the original plugin folder, identify the the template to customize.<br \/>\nCopy that template file to the geodirectory sub-folder in the active child theme.<br \/>\nMake changes to the files that are located in your child theme. <\/p>\n<h4><a href=\"#page-template\" name=\"page-template\">Override Page Template Selection<\/a><\/h4>\n<p>GeoDirectory has a built-in method for calling page templates that allows developers to override the page template selection. If you choose a page template for the &#8220;Places Detail Page&#8221;, for example, then a developer can override in this order:<\/p>\n<p>1. Does the GD Page have a Page Attributes -> Page Template selected? -> Use the selected Page Template<br \/>\n2. Is there a page override set in the design settings (there are GD settings for Details and one for Archives). -> Use the selected template.<br \/>\n3. Does the theme have a geodirectory-archive.php template?<br \/>\n4. Does the theme have a geodirectory.php template?<br \/>\n5. If none of the above then page.php template will be used.<\/p>\n<p>For examples of 3 and 4 please check out the Directory Starter and Supreme Directory child themes.<\/p>\n<h4><a href=\"#listing-data\" id=\"listing-data\">Listing Data<\/a><\/h4>\n<p>GeoDirectory V2 takes a relatively standardized approach to listing data, but it still does use custom tables (and always will). There are several reasons for the use of custom tables, but the most important reasons are performance related: speed and scalability.<\/p>\n<p>You can update GeoDirectory post info by sending the data to the standard WordPress functions like <\/p>\n<pre><code>wp_update_post()<\/code><\/pre>\n<p>. GeoDirectory hooks into the standard functions and saves the data on the fly.<\/p>\n<p>You can also get any post meta using the standard get_post_meta() function by just prefixing the field name with \u201cgeodir_\u201d so something like this will get the facebook url for the post: <\/p>\n<pre><code class='php'>\r\n$facebook_url = get_post_meta($post_id,&quot;geodir_facebook&quot;,true);\r\n<\/code><\/pre>\n<p>This approach can also be used with some <a href=\"https:\/\/wpgeodirectory.com\/docs-v2\/integrations\/builders\/\" rel=\"noopener noreferrer\" target=\"_blank\">advanced builders<\/a> that provide support for post custom fields. When the builder allows the entry of the field name, simply enter the <a href=\"https:\/\/wpgeodirectory.com\/docs-v2\/places\/custom\/\" rel=\"noopener noreferrer\" target=\"_blank\">Custom Field<\/a> key with &#8220;geodir_&#8221; in front like &#8220;geodir_facebook&#8221;.<\/p>\n<h4><a href=\"#custom-integrations\" name=\"custom-integrations\">Custom Integrations<\/a><\/h4>\n<p>Want to integrate a 3rd party plugin into your Detail page template? One approach is to use a custom shortcode. We provide an example below for how to create and render a custom shortcode to grab some listing data, in this case the post author ID. Adjust the code as needed to grab the value you want, and use the shortcode to place it where you want.<\/p>\n<p>The custom shortcode created is:<\/p>\n<pre><code class='php'>\r\n[gd_custom_shortcode]\r\n<\/code><\/pre>\n<pre><code class='php'>\r\nfunction gd_custom_shortcode( $args = array(), $content = \" ) {\r\n\tglobal $gd_post;\r\n\tif ( empty( $gd_post ) ) {\r\n\t\treturn;\r\n\t}\r\n\r\n\treturn do_shortcode( '[display-frm-data id=2051 filter=limited param=' . (int) $gd_post-&gt;post_author . ']' );\r\n}\r\nadd_shortcode( 'gd_custom_shortcode', 'gd_custom_shortcode' );\r\n<\/code><\/pre>\n<h4><a href=\"#hooks-filters\" name=\"hooks-filters\">Hooks and Filters<\/a><\/h4>\n<p>GeoDirectory V2 has a variety of hooks and filters for overriding individual functions. It is a MUCH better idea to &#8216;customize&#8217; the way that GeoDirectory works by overriding with hooks and filters than to make changes to core. GeoDirectory receives constant updates, and any changes to core will be overwritten with updates.<\/p>\n<p>The GeoDirectory V2 Codex is forthcoming, and many hooks and filters have changed. If you are looking to &#8216;do something&#8217; different and don&#8217;t know the hook or filter you are looking for, feel free to write in and describe what it is you want to do. We will do our best to point you in the right direction.<\/p>\n<h3><a href=\"#examples\" name=\"examples\">Examples<\/a><\/h3>\n<p><strong>geodir_tab_settings<\/strong><\/p>\n<p>&#8220;geodir_tab_settings&#8221; is an array of stdClass settings for filtering tabs.<\/p>\n<p><strong>Set post status after claim<\/strong><\/p>\n<pre><code class='php'>\r\n$data = apply_filters( 'geodir_pricing_complete_package_update_post_data', $data, $post_id, $package_id, $post_package_id, $revision_id );\r\n<\/code><\/pre>\n<h4><a href=\"#schema\" name=\"schema\">Schema<\/a><\/h4>\n<blockquote class=\"gd-faq\"><p>\nSchemas are used in categories to define listing data types. You can add new schemas <a href=\"https:\/\/wpgeodirectory.com\/support\/topic\/schema-type-for-custom-post-type-what-is-schema-type\/page\/3\/#post-122410\" rel=\"noopener noreferrer\" target=\"_blank\">See this topic<\/a>\n<\/p><\/blockquote>\n<h4><a href=\"#map-bubble\" name=\"map-bubble\">Map Bubble<\/a><\/h4>\n<blockquote class=\"gd-faq\"><p>\nWant to change the way the map bubble looks? Customize it.<\/p>\n<p>See https:\/\/github.com\/AyeCode\/geodirectory\/blob\/master\/templates\/map-popup.php<\/p>\n<p>To customize, create folder \/geodirectory\/ in your theme and copy file \\wp-content\\plugins\\geodirectory\\templates\\map-popup.php into the folder.<br \/>\nThe new file will be YOUR_THEME\/geodirectory\/map-popup.php.<br \/>\nNow edit file YOUR_THEME\/geodirectory\/map-popup.php and remove change the shortcode or other content to meet your needs.<\/p>\n<p>You can also try this snippet, if you unset the address from the custom fields -> Show in map bubble, this will place the address in the map bubble in a different format:<\/p>\n<pre><code class='php'>\r\nadd_filter(&quot;geodir_show_listing_info&quot;,&quot;_my_map_address_add&quot;,10,2);\r\nfunction _my_map_address_add($html,$fields_location){\r\n\r\nif($fields_location=='mapbubble'){\r\n$html = do_shortcode('[gd_post_address show=&quot;icon-label-value&quot; address_template=&quot;%%post_title%% %%post_title_br%% :: %%street_br%% %%neighbourhood_br%% %%city_br%% %%region_br%% %%zip_br%% %%country%%&quot;]').$html;\r\n}\r\n    return $html;\r\n}\r\n<\/code><\/pre>\n<\/blockquote>\n<h4><a href=\"#snippets\" name=\"snippets\">Snippets<\/a><\/h4>\n<blockquote class=\"gd-faq\"><p>\nOne of the most common ays to customize your site is by adding PHP and CSS snippets.<\/p>\n<p>CSS snippets should be kept in the Customizer, available at:<\/p>\n<p><strong>WordPress Backend &#8211; Appearance &#8211; Customizer &#8211; Additional CSS<\/strong><\/p>\n<p>Read more about CSS and <a href=\"https:\/\/wpgeodirectory.com\/docs\/customizing-your-style\/\" rel=\"noopener noreferrer\" target=\"_blank\">customizing your style here<\/a>.<\/p>\n<p>PHP snippets can be added to your site with the Code Snippets plugin.<\/p>\n<p><a href=\"https:\/\/wordpress.org\/plugins\/code-snippets\/\" rel=\"noopener noreferrer\" target=\"_blank\">https:\/\/wordpress.org\/plugins\/code-snippets\/<\/a><\/p>\n<p>We recommend this approach because theme updates will not change code stored in this way.\n<\/p><\/blockquote>\n<h3><a name=\"faq\" href=\"#faq\"><\/a>Frequently Asked Questions<\/h3>\n<blockquote><p><a name=\"map-bubble-reviews\" href=\"#map-bubble-reviews\">How do I remove reviews from the map bubble?<\/a><\/p><\/blockquote>\n<p>Customize <\/p>\n<pre><code>geodirectory\/templates\/map-popup.php<\/code><\/pre>\n","protected":false},"featured_media":0,"parent":84,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","doc_tag":[],"amp_validity":null,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/wpgeodirectory.com\/docs-v2\/wp-json\/wp\/v2\/docs\/164"}],"collection":[{"href":"https:\/\/wpgeodirectory.com\/docs-v2\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/wpgeodirectory.com\/docs-v2\/wp-json\/wp\/v2\/types\/docs"}],"replies":[{"embeddable":true,"href":"https:\/\/wpgeodirectory.com\/docs-v2\/wp-json\/wp\/v2\/comments?post=164"}],"version-history":[{"count":0,"href":"https:\/\/wpgeodirectory.com\/docs-v2\/wp-json\/wp\/v2\/docs\/164\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/wpgeodirectory.com\/docs-v2\/wp-json\/wp\/v2\/docs\/84"}],"next":[{"title":"Common Examples of Customization","link":"https:\/\/wpgeodirectory.com\/docs-v2\/faq\/common-examples\/","href":"https:\/\/wpgeodirectory.com\/docs-v2\/wp-json\/wp\/v2\/docs\/395"}],"wp:attachment":[{"href":"https:\/\/wpgeodirectory.com\/docs-v2\/wp-json\/wp\/v2\/media?parent=164"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/docs-v2\/wp-json\/wp\/v2\/doc_tag?post=164"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}