1. Home
  2. Places
  3. Places Settings – Custom Fields

Places Settings – Custom Fields


Introduction
Settings
Support
FAQ – Frequently Asked Questions

Introduction

Find the Places Settings – Custom Fields Tabs (tab) in the backend.

Default Settings

Field Settings

Show Advanced

To see all of the field settings and options described below be sure to click the “Show Advanced” button at the bottom of each field.

Field Data Type

Text fields allow you to specify which type of data is to be stored. This settings can have an effect on which options are available for custom search.

Admin Name

Used in the backend only to help you keep track of your fields. Admin name and key both need to be unique.

Field Label

What is entered here is shown to your users on the listing form and is also available with GD Post Meta as the “label” option.

Field Description

Instructions for the user when they are viewing the field in the context of the form.

Field Key

This is the name of the variable for this field, and is also used as the column name when listings are imported and exported. Keys must be unique within a CPT.

Is active

Only fields marked active will show up on the listing form.

Admin only edit

Set this option to make the field accessible to admins only in the form. Fields set for admin only edit cannot be changed by listing owners, but can still be displayed on the frontend.

Default value

You can add a default simple value text that will be present in the field when a new listing is added. Instead of a default value, consider using a placeholder instead.

The default value may be saved with the form, so, be sure to use a value that will encourage users to add their own value but that won’t cause them problems if they fail to add something unique.

Placeholder Value

The Placeholder value is the kind of text that disappears when the user clicks and focuses on the field. This is a great way to give a hint to your users about how they should add their value to the field, especially in cases where they should follow a specific format, like a phone field where you require a country code or specifically don’t want a country code.

Show in extra output location

Choose which locations should display the custom field. This field requires the GD Output Locations widget to show the values. Read more about this in the section below.

Show on only these price packages

Choose which price packages should include the field. Similar settings are available in the Packages tab.

Is required

Make the field required.

Validation pattern

Text and phone fields allow a regex expression for HTML5 pattern validation. See examples below.

Validation Message

If the field fails validation on submission this message can be displayed.

Icon

Select a Font Awesome icon class to use GD Post Meta options for display of the icon with the field value.

CSS class

Set a custom CSS class that will be output whenever the field is shown on the frontend with GD Post Meta or other GD elements.

Post Sort Options – Include this field in the sorting options.

Set the option here to make the field show up on the Sorting tab where it can be used in the configuration of sorting options for Archive pages.

Field Usage

Show Custom Fields on Listings

The easy way to show custom fields is to use the GD Single Tabs and GD Output Locations elements.

GD Single Tabs

Every custom field that you add to your Custom Post Type is made available in the Tabs. You can read more about how to setup Tabs for your listing here.

GD Output Location

Each field that you add to your listing has an option “Show in extra output locations”. You can set three possible location values in this field:

  • Detail Page sidebar
  • Listing
  • Map Bubble

Now that you have set a display location for the field, there is a second step to setup display. You will need to add the GD Output Location widget to your GD templates.

Detail Page Sidebar

To show custom fields in the Detail page sidebar, add the GD Output Location widget to the sidebar that is shown on the Details page template. You can use the setup wizard to do this.

Archive Item template

To show custom fields in the Listings, add the GD Output Location element to the Archive Item template. This is setup in the default content when GD is installed.

Map Bubble

To show custom fields in the Map Bubble, no further steps are necessary because the GD Output Location element is included in the Map Bubble template by default.

Read more about the GD Output Location Element: https://wpgeodirectory.com/docs-v2/geodirectory/personalize/#show

Address

How can I make the address optional?
The only way to remove the requirement for address is to turn off the physical location for the CPT, removing the address from all existing locations. The option is in the setting
Places – Settings – General – Disable physical location

Why is the country field still showing on the add-listing form when I un-checked “Show country in address?”?
This field is only for the display on the frontend, and does not remove the country from the form. All address fields except neighborhood are required.

Business Hours

Business Hours allows listing owners to set their open times. Business hours INPUT is done in 24 hour mode, but is shown on the frontend using whatever display format is set in WP Settings. Monday is currently fixed as a start dat.

When you setup your Custom Post Type, also take a moment to revisit the sitewide settings for date time display format and timezone, because both are important for the business hours feature.

You can change these site settings in:
WordPress – Settings – General

Time Zone

Business hours has a special timezone feature. When a listing is added or edited, and the map pin is changed, if the address is checked from the API, then the timezone of the address is also retrieved.

The timezone of the business hours is then updated with an offset. For example, if the site timezone is GMT (0), and a listing is added in Philadelphia, the timezone offset is updated as follows:

For more information see this topic: https://wpgeodirectory.com/support/topic/gd-v2-0-0-55-business-hours-issue/page/2/#post-486387

Open times past midnight

To set open times that go past midnight/11:59/23:59 use the following kinds of settings, where the time after midnight is set on the next day. For example, if a shop is open until 4am Tuesday morning, then set the open time on Monday to last until 23:59, then the time on Tuesday to start at 00:00 and end at 04:00.

Custom Class gd-bh-expanded – Show open by default

Add the custom class to the widget or shortcode to show the business hours open by default:

gd-bh-expanded

Business Hours CSS examples:


/* GeoDirectory V2 Business Hours Styles*/
.geodir-field-business_hours {
    text-align: inherit !important;
}
/* GeoDirectory V2 Business Hours  – Start open and stay open*/
.gd-bh-open-hours {
    display: block !important;
}

/* GeoDirectory V2 Business Hours – hide the toggle so it cannot be closed*/
span.gd-bh-expand-range {
    display: none;
}
/* GeoDirectory V2 Business Hours – hide closed days and times*/
.gd-bh-days-closed{
display:none;
}

Business Hours Import and Export

You can import and export business hours; here’s an example showing closed on Sunday (no hours) and open 24 hours on Monday ( Mo 00:00-00:00 ).


["Mo 00:00-00:00","Tu 09:00-17:00","We 09:00-17:00","Th 09:00-17:00","Fr 20:00-00:00","Sa 00:00-04:00"],["UTC":"+0:00"]

Email

Setup of Ninja Forms integration for a GeoDirectory contact form requires that the listing has an email field with the key “email” as shown below:

Featured

“Featured” is a pre-defined checkbox field. It can only be used once on each Custom Post Type.

The Featured field has 3 integrations that make it stand out from other pre-defined fields.

  1. Available as a filter for GD Listings – Show only featured listings
  2. Available as a sorting option for GD Loop – Set “Featured, Descending” to show all featured listings first on Archive – See Sorting
  3. Pricing Mnaager Integration – Automate “Featured” using Price Package Settings. See Packages.

The Pricing Manager integration makes it possible to ‘reward’ paid listing owners with all the special features mentioned above automatically. When a listing is paid for, with a package that includes ‘featured’, then the listing is marked featured and can be shown in special lists as well as appear first in sorting. Featured is the most common field used for this kind of promotion of paid listings. There is also another doc focused on featured listings and options for decorating them, too.

With Pricing Manager installed, the Featured field is completely managed by the settings in the Price package applied to the listing. If you set a default value for the field, that default will be shown when a new listing is created, but, once the listing is saved with a price package, the package settings will adjust the value of the field automatically.

Include the featured field in Price Packages to set the value automatically.

As soon as the Pricing Manager addon is installed, it is no longer possible to override the value of the featured field for a listing by editing it manually. If you are looking for an ad hoc way to group and filter listings for GD Listings, you can also use categories or tags. See the Tags section for more info.

The key for the feature field is

featured

.

Tags

Tags are ad-hoc words or phrases that can be assigned to a listing. Tags are special because each tag gets at least one Archive page where all the listings with that tag are listed next to each other.

GeoDirectory uses the default user interface for adding or removing tags in the backend, and then a multi-select field for the frontend edit form.

Tags are the best choice for ad-hoc ‘grouping’ of listings for filtering with GD Listings. For example, say you have a group of 5 places out of 1000 and you want to show them on a new Post with GD Listings. Just use Quick Edit in the Places listing to add the same tag to each listing. Then setup your GD Listings to include only listings with that tag.

In many cases, tags are so useful for curated sites that a site manager will choose to make the field “Admin only”. That means that the site administrators can always edit the tags, but that the listing owners can’t. That way you can use the Tags field for your own Administrative purposes like grouping similar listings.

Textarea and Video Field

Post Description and Video fields are Textareas

The listing description field and video fields are both examples of textarea fields. You can add as many textareas to the listing form as you like.

Textarea fields have two special options:

Show advanced editor

Shows the advanced editor on the listing form. This makes it easier for your site visitors to markup their text with bold or italics or links. Be careful with this setting, because of course users may enter broken HTML that will break your page layout.

Embed Media URLs

This option will force additional processing on the field. Video service URLs like a youtube video link will be turned into an embedded video. Also, shortcodes entered into the field will be rendered.
Tip: Try instructing your users with the “Field Description” that they should simply “Use the simple URL, as opposed to an iFrame or oEmbed like: https://www.youtube.com/watch?v=jX38T-ZmATI”

iFrame and Scripts in Custom Fields

By default GeoDirectory will strip advanced scripts and iFrames from all fields. This is a normal security precaution in keeping with General WordPress policies to protect site owners from the injection of malicious code through fields that are available to end users.

You can use the following snippets to disable the sanitization of individual fields or by field type.

An example for adding an admin only field for an Iframe can be found here: https://wpgeodirectory.com/support/topic/streaming-reviews/#post-514812

WARNING – WARNING – Skipping sanitize routine for field values may result in a Cross-Site Scripting Attack (XSS) on your site.

Field Types Example


/**
 * Skip sanitize based on field type.
 *
 * WARNING – Skipping sanitize routine for field values may result in a Cross-Site Scripting Attack (XSS) on your site.
 * */
add_filter( 'geodir_custom_field_value_email', 'gd_snippet_custom_skip_sanitize_field', 11, 6 );
add_filter( 'geodir_custom_field_value_html', 'gd_snippet_custom_skip_sanitize_field', 11, 6 );
add_filter( 'geodir_custom_field_value_phone', 'gd_snippet_custom_skip_sanitize_field', 11, 6 );
add_filter( 'geodir_custom_field_value_text', 'gd_snippet_custom_skip_sanitize_field', 11, 6 );
add_filter( 'geodir_custom_field_value_textarea', 'gd_snippet_custom_skip_sanitize_field', 11, 6 );
add_filter( 'geodir_custom_field_value_url', 'gd_snippet_custom_skip_sanitize_field', 11, 6 );

Several Individual Fields Example


/**
 * Skip sanitize for several specific field values.
 *
 * WARNING – Skipping sanitize routine for field values may result in a Cross-Site Scripting Attack (XSS) on your site.
 */
function gd_snippet_custom_skip_sanitize_field( $value, $gd_post, $custom_field, $post_id, $post, $update ) {
	// Fields to skip strip tags.
	$skip_strip_tags = array();
	$skip_strip_tags[] = 'custom_field';
	$skip_strip_tags[] = 'custom_text';
	$skip_strip_tags[] = 'my_field';

	if ( in_array( $custom_field->htmlvar_name, $skip_strip_tags ) ) {
		$value = $gd_post[ $custom_field->htmlvar_name ];

		if ( isset( $custom_field->data_type ) && ( $custom_field->data_type == 'DECIMAL' || $custom_field->data_type == 'INT' ) && $value === "" ) {
			$value = null;
		}
	}
	return $value;
}

Post Content (Description) Field Example


/**
 * Skip sanitize for the post_content field
 *
 * WARNING – Skipping sanitize routine for field values may result in a Cross-Site Scripting Attack (XSS) on your site.
 */
function gd_snippet_custom_skip_sanitize_field( $value, $gd_post, $custom_field, $post_id, $post, $update ) {
    // Fields to skip strip tags.
    $skip_strip_tags = array();
    $skip_strip_tags[] = 'post_content';
    if ( in_array( $custom_field->htmlvar_name, $skip_strip_tags ) ) {
        $value = $gd_post[ $custom_field->htmlvar_name ];
        if ( isset( $custom_field->data_type ) && ( $custom_field->data_type == 'DECIMAL' || $custom_field->data_type == 'INT' ) && $value === "" ) {
            $value = null;
        }
    }
    return $value;
}

Video Textarea Field Types Example


/**
 * Skip sanitize for the video field
 *
 * WARNING – Skipping sanitize routine for field values may result in a Cross-Site Scripting Attack (XSS) on your site.
 */
function gd_snippet_custom_skip_sanitize_field( $value, $gd_post, $custom_field, $post_id, $post, $update ) {
    // Fields to skip strip tags.
    $skip_strip_tags = array();
    $skip_strip_tags[] = 'video';
    if ( in_array( $custom_field->htmlvar_name, $skip_strip_tags ) ) {
        $value = $gd_post[ $custom_field->htmlvar_name ];
        if ( isset( $custom_field->data_type ) && ( $custom_field->data_type == 'DECIMAL' || $custom_field->data_type == 'INT' ) && $value === "" ) {
            $value = null;
        }
    }
    return $value;
}

GD Post Meta

GD Post Meta can be used to display the complete content of a textarea field. GD Post Meta can be used in Detail page tabs or the Detail page sidebar. If you add the default “Description” field to a tab, it will be displayed with GD Post Meta. If you add a custom GD Post Meta shortcode to the tabs or as a widget you can use advanced options to show the field label, icon, or just the value. You can also use the show field to ‘strip tags’ which means to output text only instead of markup like bold or italics.

GD Post Content

GD Post Content is most useful and designed for use on the GD Archive Item. GD Post Content comes with options to display a maximum number of words and to include an optional “Read More” type link.

Advanced Settings for shortcodes and video URLs

Textarea fields have a special advanced setting to “Enable Embedded Media”. When this setting is enabled, then any embedded media links like Youtube videos will be rendered.
Also, shortcodes will be rendered.

URL field

URL fields are a great way to allow listing owners to share links to their social profiles or event ticket sales.

Each URL field accepts a single URL. Validation for the format is built in, so http:// or https:// is required, to make sure that your site users are submitting links that can actually be clicked.

The field label of the URL field is used as the default link text. For example, when the field label is “Website”, then the URL uses “Website” as the link text.

The user can override the field label title setting by adding a | (pipe) character and inputting their link text after the pipe. If you want to encourage users to override the label then give then try adding the following as placeholder and field description:
Field Description: “You can enter the link title if you add your link in this format : https://mylink.com|My Link Title”
Placeholder:


https://facebook.com/myfbpagereally|My link title text

This allows the user to alter the text like this

Show the URL instead of the label with a snippet.

Field validation

GDV2 introduces Validation for text and phone fields. Field validation means that you can enter an HTML5 regex rule to govern what the user is allowed to input in the field. If they don’t enter the information correctly (to match the rule you use) then they will be shown an error.

Below we show some commonly used example rules but you can always make your own or find more information on sites like this one: http://regexlib.com/Search.aspx?k=phone+number

To use them, just copy from the portion in red and add to the HTML5 Regex field. More examples can be found here.

.{3,}

3 characters minimum

.{5,10}

5 to 10 characters

.{0}|.{5,10}

Either 0 OR (5 to 10 chars)

.{0}|.{8,}

Either 0 OR (8 chars minimum)

.{0}|.{0,40}

Either 0 OR (40 chars maximum)

[0-9]

Enter only numbers (error if not 0123456789)

[\+]\d{2}[\(]\d{2}[\)]\d{4}[\-]\d{4}

US Phone number in international format

The rule for 40 characters maximum is shown here being applied to the summary text field.

On submit/save, the field is validated and an error is presented while the saving of the page is blocked.

If you want to make use of smaller blurbs of text use a text field instead of a textarea and then set a character limit on field. That way you can make sure your listing owners don’t put in so much text that your page layout will break. Textarea fields do not support validation.

Get Support

Get support on our forum, fnd out more here: https://wpgeodirectory.com/docs-v2/v2/support/

FAQ – Frequently Asked Questions

Why doesn’t my new field show?

When new fields are added, review these settings to get them to show in the forms and on the details.

Field not showing in the add-listing form

Click the Show Advanced Button at the bottom to see all the options

Is Active? – Make sure the field is active or it won’t show up anywhere

Admin only edit? – Make sure this is unchecked if you want admins to be able to fill the field

Show only on these price packages – Select the packages that can access this field. If no packages are selected the field won’t be visisble at all, even to admins.

Field not showing with GD Output Location -> map bubble, listings, or details page sidebar

Show in Extra Output Location? – Add Output Locations to show the field using the GD Output Location Widget on the frontend

Show on details page sidebar – Add GD Output Location in the sidebar to show fields that are set to display there

How do I add a second video field?

There can be only one video field using the predefined video field, but you can add as many textarea fields as you like.

>Can I export the custom fields for a CPT and import them into another CPT?

At this time no, but this is being looked at for a future version.

Can I add the same field to each CPT at the same time??

Each CPT is independent. The fields can have the same ‘key’ for each CPT. If they have the same key then they are named the same in the export and import and accessed with the same key variable in templates.
Even if they have the same key, though, the fields are independent and you will want to configure the options for each one.

Can I add the same field to each CPT at the same time??

At this time no, but this is being looked at for a future version.

Why is HTML being stripped from the Description (textarea) field?

There are 3 possibilities:

1. Visit the Description custom field, and make sure the Advanced Editor has been enabled.

2. Visit the Package advanced settings and make sure that the option to Disable HTML has not been selected

3. The HTML you are adding is an advanced script, and a snippet to disable stripping of scripts must be added. This is not recommended (see snippets above)

Was this helpful to you? Yes 7 No 8