1. Home
  2. Docs
  3. FAQ
  4. Customizing GeoDirectory

Customizing GeoDirectory


Introduction
Frequently Asked Questions

Introduction

We hope you find most options for personalizing GeoDirectory suitable for your needs. Personalizing means using GeoDirectory’s built in options for managing tabs or page design to place or arrange any of the GD page elements.

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 we don’t provide support for customization, we do want to encourage your customizing GeoDirectory (without making changes to core!) because we do like to see you make GeoDirectory your own.

Adding Custom Code

CSS

We recommend that you add custom CSS code to the WordPress Customizer. You can find the “Additional CSS” option at:

WordPress – Appearance – Customizer – Additional CSS

PHP

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 Code Snippets plugin here.

Templates

GeoDirectory uses a number of special templates to create the pages that make up the directory.

Default templates can be found at

/wp-content/plugins/geodirectory/templates

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:

The default templates are located in the plugin folder

/wp-content/plugins/geodirectory/templates

Navigate to the folder for your active child theme.
Create a new sub-folder called geodirectory.
Example of the new sub-folder for a child theme called ‘mycildtheme’

/wp-content/themes/mychildtheme/geodirectory/

Template Overrides

In the original plugin folder, identify the the template to customize.
Copy that template file to the geodirectory sub-folder in the active child theme.
Make changes to the files that are located in your child theme.

Override Page Template Selection

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 “Places Detail Page”, for example, then a developer can override in this order:

1. Does the GD Page have a Page Attributes -> Page Template selected? -> Use the selected Page Template
2. Is there a page override set in the design settings (there are GD settings for Details and one for Archives). -> Use the selected template.
3. Does the theme have a geodirectory-archive.php template?
4. Does the theme have a geodirectory.php template?
5. If none of the above then page.php template will be used.

For examples of 3 and 4 please check out the Directory Starter and Supreme Directory child themes.

Listing Data

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.

You can update GeoDirectory post info by sending the data to the standard WordPress functions like wp_update_post(). GeoDirectory hooks into the standard functions and saves the data on the fly.

You can also get any post meta using the standard get_post_meta() function by just prefixing the field name with “geodir_” so something like this will get the facebook url for the post:

$facebook_url = get_post_meta($post_id,"geodir_facebook",true);

This approach can also be used with some advanced builders that provide support for post custom fields. When the builder allows the entry of the field name, simply enter the Custom Field key with “geodir_” in front like “geodir_facebook”.

Custom Integrations

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.

The custom shortcode created is:

[gd_custom_shortcode]
function gd_custom_shortcode( $args = array(), $content = '' ) {
	global $gd_post;
	if ( empty( $gd_post ) ) {
		return;
	}

	return do_shortcode( '[display-frm-data id=2051 filter=limited param=' . (int) $gd_post->post_author . ']' );
}
add_shortcode( 'gd_custom_shortcode', 'gd_custom_shortcode' );

Hooks and Filters

GeoDirectory V2 has a variety of hooks and filters for overriding individual functions. It is a MUCH better idea to ‘customize’ 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.

The GeoDirectory V2 Codex is forthcoming, and many hooks and filters have changed. If you are looking to ‘do something’ different and don’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.

Examples

geodir_tab_settings

“geodir_tab_settings” is an array of stdClass settings for filtering tabs.

Set post status after claim

$data = apply_filters( 'geodir_pricing_complete_package_update_post_data', $data, $post_id, $package_id, $post_package_id, $revision_id );

Schema

Schemas are used in categories to define listing data types. You can add new schemas See this topic

Map Bubble

Want to change the way the map bubble looks? Customize it.

See https://github.com/AyeCode/geodirectory/blob/master/templates/map-popup.php

To customize, create folder /geodirectory/ in your theme and copy file \wp-content\plugins\geodirectory\templates\map-popup.php into the folder.
The new file will be YOUR_THEME/geodirectory/map-popup.php.
Now edit file YOUR_THEME/geodirectory/map-popup.php and remove change the shortcode or other content to meet your needs.

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:

add_filter("geodir_show_listing_info","_my_map_address_add",10,2);
function _my_map_address_add($html,$fields_location){

if($fields_location=='mapbubble'){
$html = do_shortcode('[gd_post_address show="icon-label-value" address_template="%%post_title%% %%post_title_br%% :: %%street_br%% %%neighbourhood_br%% %%city_br%% %%region_br%% %%zip_br%% %%country%%"]').$html;
}
    return $html;
}

Snippets

One of the most common ays to customize your site is by adding PHP and CSS snippets.

CSS snippets should be kept in the Customizer, available at:

WordPress Backend – Appearance – Customizer – Additional CSS

Read more about CSS and customizing your style here.

PHP snippets can be added to your site with the Code Snippets plugin.

https://wordpress.org/plugins/code-snippets/

We recommend this approach because theme updates will not change code stored in this way.

Frequently Asked Questions

How do I remove reviews from the map bubble?

Customize geodirectory/templates/map-popup.php

Was this article helpful to you? Yes 1 No