{"id":2471,"date":"2026-10-20T08:33:27","date_gmt":"2026-10-20T07:33:27","guid":{"rendered":"https:\/\/wpgeodirectory.com\/documentation\/article\/add-custom-fields-and-predefined-fields\/"},"modified":"2026-10-20T08:56:41","modified_gmt":"2026-10-20T07:56:41","slug":"add-custom-fields-and-predefined-fields","status":"publish","type":"gd_place","link":"https:\/\/wpgeodirectory.com\/documentation\/article\/core-features\/add-custom-fields-and-predefined-fields\/","title":{"rendered":"How to add custom fields and your own predefined fields"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">You add fields to the listing form of each post type in GeoDirectory under Places &gt; Settings &gt; Custom Fields (or the same screen for your other post types). The panel on the right has the field types you can add:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Standard Fields are the basic input types, such as text, textarea, select, checkbox, date and file upload.<\/li>\n\n\n\n<li>Predefined Fields are ready made fields with sensible settings, such as Business Hours, Contact Email, Website, Facebook, X, Price and Video.<\/li>\n\n\n\n<li>A third group, Custom Fields, only appears when a plugin or snippet adds fields to it.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Click a field type, fill in its label and settings, and save. Drag fields in the list on the left to change their order on the form. See <a href=\"https:\/\/wpgeodirectory.com\/documentation\/article\/how-tos\/how-to-add-a-custom-field-to-custom-post-type\/\">How to add a custom field to a custom post type<\/a> for a walk through.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Add your own predefined field<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you add the same field to many sites or post types, you can add it to the Predefined Fields list with the <code>geodir_custom_fields_predefined<\/code> filter. This example adds a LinkedIn URL field:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-php\">add_filter( &#039;geodir_custom_fields_predefined&#039;, &#039;my_gd_predefined_fields&#039;, 10, 2 );\nfunction my_gd_predefined_fields( $custom_fields, $post_type ) {\n\t$custom_fields&#091;&#039;linkedin&#039;&#093; = array(\n\t\t&#039;field_type&#039;  =&gt; &#039;url&#039;,\n\t\t&#039;class&#039;       =&gt; &#039;gd-linkedin&#039;,\n\t\t&#039;icon&#039;        =&gt; &#039;fab fa-linkedin&#039;,\n\t\t&#039;name&#039;        =&gt; &#039;LinkedIn&#039;,\n\t\t&#039;description&#039; =&gt; &#039;Adds a LinkedIn URL input.&#039;,\n\t\t&#039;defaults&#039;    =&gt; array(\n\t\t\t&#039;data_type&#039;          =&gt; &#039;TEXT&#039;,\n\t\t\t&#039;admin_title&#039;        =&gt; &#039;LinkedIn&#039;,\n\t\t\t&#039;frontend_title&#039;     =&gt; &#039;LinkedIn&#039;,\n\t\t\t&#039;frontend_desc&#039;      =&gt; &#039;Enter your LinkedIn page URL.&#039;,\n\t\t\t&#039;htmlvar_name&#039;       =&gt; &#039;linkedin&#039;,\n\t\t\t&#039;is_active&#039;          =&gt; true,\n\t\t\t&#039;for_admin_use&#039;      =&gt; false,\n\t\t\t&#039;default_value&#039;      =&gt; &#039;&#039;,\n\t\t\t&#039;show_in&#039;            =&gt; &#039;&#091;detail&#093;&#039;,\n\t\t\t&#039;is_required&#039;        =&gt; false,\n\t\t\t&#039;option_values&#039;      =&gt; &#039;&#039;,\n\t\t\t&#039;validation_pattern&#039; =&gt; &#039;&#039;,\n\t\t\t&#039;validation_msg&#039;     =&gt; &#039;&#039;,\n\t\t\t&#039;required_msg&#039;       =&gt; &#039;&#039;,\n\t\t\t&#039;field_icon&#039;         =&gt; &#039;fab fa-linkedin&#039;,\n\t\t\t&#039;css_class&#039;          =&gt; &#039;&#039;,\n\t\t\t&#039;cat_sort&#039;           =&gt; false,\n\t\t\t&#039;cat_filter&#039;         =&gt; false,\n\t\t),\n\t);\n\n\treturn $custom_fields;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The array key and <code>htmlvar_name<\/code> must be unique and contain no spaces. <code>field_type<\/code> is one of the standard field types, and the <code>defaults<\/code> are the settings the field starts with when you add it, which you can still change afterwards. The <code>$post_type<\/code> argument lets you add a field for one post type only.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Add the snippet with the <a href=\"https:\/\/wpgeodirectory.com\/documentation\/article\/useful-plugins\/code-snippets-plugin\/\">Code Snippets plugin<\/a>, then reload the Custom Fields screen and the new field is in the Predefined Fields list.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You add fields to the listing form of each post type in GeoDirectory under Places &gt; Settings &gt; Custom Fields (or the same screen for your other post types). The panel on the right has the field types you can add: Click a field type, fill in its label and settings, and save. Drag fields [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"article\/tags":[],"article\/categories":[421,213],"class_list":["post-2471","gd_place","type-gd_place","status-publish","hentry","gd_placecategory-core-features","gd_placecategory-extensions-features"],"_links":{"self":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/2471","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=2471"}],"version-history":[{"count":2,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/2471\/revisions"}],"predecessor-version":[{"id":2725,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/2471\/revisions\/2725"}],"wp:attachment":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/media?parent=2471"}],"wp:term":[{"taxonomy":"gd_place_tags","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/tags?post=2471"},{"taxonomy":"gd_placecategory","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/categories?post=2471"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}