{"id":901,"date":"2025-03-24T14:27:58","date_gmt":"2025-03-24T14:27:58","guid":{"rendered":"https:\/\/wpgeodirectory.com\/documentation\/article\/customizing-templates\/"},"modified":"2025-04-03T15:24:19","modified_gmt":"2025-04-03T14:24:19","slug":"customizing-templates","status":"publish","type":"gd_place","link":"https:\/\/wpgeodirectory.com\/documentation\/article\/how-tos\/customizing-templates\/","title":{"rendered":"Customizing templates"},"content":{"rendered":"\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\">GeoDirectory <strong>template files contain the code and template structure<\/strong> for the frontend of your site and HTML emails sent by your system.<\/span><\/div>\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\">GD uses Bootstrap styles by default. Customizing templates means moving a copy of a GD file to your folder, and that needs to include a Bootstrap sub-folder, ex.<br>copy \u2026\/wp-content\/plugins\/geodirectory\/templates\/bootstrap\/map\/map-popup.php\u00a0<br>to\u00a0 \u00a0 \u00a0\u2026\/wp-content\/themes\/your-theme\/geodirectory\/bootstrap\/map\/map-popup.php<\/span><\/div>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Templates can be found at <strong>&#8230;\/wp-content\/plugins\/<\/strong> <strong>geodirectory\/templates<\/strong><\/li>\n\n\n\n<li>Email templates can be found at <strong>&#8230;\/<\/strong> <strong>wp-content\/plugins\/geodirectory\/templates\/emails<\/strong><\/li>\n<\/ul>\n\n\n\n<p>When you open these files, you will notice they all contain <strong>hooks<\/strong> that allow you to <strong>customize content<\/strong> without needing to edit the template files themselves. This method protects you from losing your customization when updating your plugins, because the template files can be left completely untouched.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Editing template files<\/h2>\n\n\n\n<div class=\"wp-block-blockstrap-blockstrap-widget-alert d-flex align-items-center fade show alert alert-warning mb-3\" role=\"alert\"><span class=\"fas fa-exclamation-triangle me-2\"><\/span><span class=\"flex-grow-1\">To <strong>keep your customization safe<\/strong> from plugin updates, you should create copies of the templates in your theme folder.\u00a0 <strong>Do not edit these files within the core plugin itself<\/strong> as they are overwritten during the upgrade process and any customization will be lost.<\/span><\/div>\n\n\n\n<p>Copy the template into a folder within your (child) theme named <strong>\/geodirectory\/<\/strong> keeping\u00a0the same file structure as within the plugin files, but\u00a0remove the<strong> \/templates\/\u00a0<\/strong>sub-folder.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Example 1: frontend template<\/h2>\n\n\n\n<p>To override the map bubble template file when you use the Whoop theme, copy the<br><br><strong>\u2026\/wp-content\/plugins\/geodirectory\/templates\/<\/strong><strong>map-popup.php&nbsp;<\/strong><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wpgeodirectory.com\/documentation\/wp-content\/uploads\/2025\/03\/file-H5yaSuy4mV.png\" srcset=\"https:\/\/wpgeodirectory.com\/documentation\/wp-content\/uploads\/2025\/03\/file-H5yaSuy4mV.png 438w, https:\/\/wpgeodirectory.com\/documentation\/wp-content\/uploads\/2025\/03\/file-H5yaSuy4mV-300x165.png 300w\" alt=\"\" width=\"438\" height=\"241\">file to <strong>\u2026\/wp-content\/themes\/whoop\/geodirectory\/map-popup.php<\/strong><br><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wpgeodirectory.com\/documentation\/wp-content\/uploads\/2025\/03\/file-2CeKTShoYk.png\" srcset=\"https:\/\/wpgeodirectory.com\/documentation\/wp-content\/uploads\/2025\/03\/file-2CeKTShoYk.png 383w, https:\/\/wpgeodirectory.com\/documentation\/wp-content\/uploads\/2025\/03\/file-2CeKTShoYk-300x143.png 300w\" alt=\"\" width=\"383\" height=\"183\"><\/p>\n\n\n\n<p>The copied file will now override the GeoDirectory default template file.&nbsp;<\/p>\n\n\n\n<div class=\"wp-block-blockstrap-blockstrap-widget-alert d-flex align-items-center fade show alert alert-warning mb-3\" role=\"alert\"><span class=\"fas fa-exclamation-triangle me-2\"><\/span><span class=\"flex-grow-1\">However, bear in mind that when AyeCode UI (Bootstrap) is active, you need to\u00a0copy the\u00a0<br><strong>\u2026\/wp-content\/plugins\/geodirectory\/templates\/bootstrap\/map\/map-popup.php\u00a0<\/strong>file to\u00a0<strong>\u2026\/wp-content\/themes\/your-theme\/geodirectory\/bootstrap\/map\/map-popup.php<\/strong>This is some information you should read<\/span><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Example 2: Email template<\/h2>\n\n\n\n<p>To override the email footer template file when you use the Supreme theme, copy the\u00a0<br><strong>&#8230;\/wp-content\/plugins\/geodirectory\/templates\/emails\/<\/strong><strong>geodir-email-footer.php<\/strong><br>file to<br><strong>&#8230;\/wp-content\/themes\/supreme-directory\/geodirectory\/emails\/<\/strong><strong>geodir-email-footer.php<\/strong><\/p>\n\n\n\n<p>The copied file will now override the GeoDirectory default email footer file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Example 3: PHP for GD Custom Fields<\/h2>\n\n\n\n<p>Try the geodir_get_post_meta() function to retrieve the GD custom field value for the GD listing (see <a href=\"https:\/\/github.com\/AyeCode\/geodirectory\/blob\/master\/includes\/post-functions.php#L233\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/AyeCode\/geodirectory\/blob\/master\/includes\/post-functions.php#L233<\/a>).<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-php\">$maybe_meta = geodir_get_post_meta( $object_id, $meta_key, $single );\n\n\/\/ Email Example\n$email = geodir_get_post_meta( $post_id, &#039;email&#039;, true );<\/code><\/pre>\n\n\n\n<p><br>Try the geodir_save_post_meta() function to update the GD custom field value for the GD listing (see <a href=\"https:\/\/github.com\/AyeCode\/geodirectory\/blob\/master\/includes\/post-functions.php#L104\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/AyeCode\/geodirectory\/blob\/master\/includes\/post-functions.php#L104<\/a>).<br><\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-php\">\/\/ Email Example:\ngeodir_save_post_meta( $post_id, &#039;email&#039;, &#039;myemail@mysite.com&#039; );<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>When you open these files, you will notice they all contain hooks that allow you to customize content without needing to edit the template files themselves. This method protects you from losing your customization when updating your plugins, because the template files can be left completely untouched. Editing template files Copy the template into a [&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],"class_list":["post-901","gd_place","type-gd_place","status-publish","hentry","gd_placecategory-tips-tricks-more","gd_placecategory-how-tos"],"_links":{"self":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/901","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=901"}],"version-history":[{"count":0,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/901\/revisions"}],"wp:attachment":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/media?parent=901"}],"wp:term":[{"taxonomy":"gd_place_tags","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/tags?post=901"},{"taxonomy":"gd_placecategory","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/categories?post=901"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}