Common code snippets

On this page:

Introduction Add the package ID to the body attribute Adding CPT-specific content on top of the Add Listing page Making the listing description optional Sorting on Listings pages: Featured first, then alphabetic Detail Page Hide ‘No Reviews’ Remove GD Scripts Supreme Directory Showing icons instead of category links in list and grid view

Introduction

We recommend using the Code Snippets plugin to add custom PHP code.
CSS can be added to GD > Design > Scripts

Add the package ID to the body attribute

  1. If you want to change the looks of the detail page depending on the price package, you can do that by adding the ID to the code of the detail page:
  2. To do this, add this code to your child theme’s functions.php file:

    [php]
    // add the package id to the body
    add_filter( ‘body_class’, ‘my_add_package_class’,10,1 );
    function my_add_package_class($class){
    global $post;
    if (geodir_is_page(‘detail’) && isset($post->package_id)) {
    $class[] = "gd-package-id-".$post->package_id;
    }
    return $class;
    }
    [/php]

  3. You can now target elements of the detail page using the package ID class, for example

    [css]
    .gd-package-id-1 .geodir-tags {display: none}
    [/css]

    would hide tags for price packages with ID 1.

Adding CPT-specific content on top of the Add Listing page

  1. If you want to add any special content to your Add Listing page, you can just add that in the content section using the normal way of editing your WP page “Add Listing”.
  2. If you want to add content specific to a CPT you can use this code, adjust as required:

    [php]
    function geodir_add_place_before_main_content_custom() {
    if (isset($_GET[‘listing_type’]) && $_GET[‘listing_type’] == ‘gd_place’) {
    ?>

    <div>bla bla</div>

    <?php
    }
    }
    add_action(‘geodir_add_listing_before_main_content’, ‘geodir_add_place_before_main_content_custom’);
    [/php]

Making the listing description optional

  1. The listing description field on the Add Listing page is a required field by default.
  2. You can make the description field optional by adding some JS and CSS code.
  3. Add the following code to GD > Design > Scripts tab > Footer script code:

    [javascript]
    <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%20type%3D%22text%2Fjavascript%22%3E%0AjQuery(%20document%20).ready(function()%20%7B%0A%20%20%20%20jQuery(%22%23geodir_post_desc_row%22).removeClass(%22required_field%22)%3B%0A%7D)%3B%0A%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="&lt;script&gt;" title="&lt;script&gt;" />
    [/javascript]

  4. Also add the following CSS code:

    [css]
    #geodir_post_desc_row label span,
    #geodir_post_desc_row .geodir_message_error {
    display:none !important;
    }
    [/css]

Sorting on Listings pages: Featured first, then alphabetic

  1. The sorting options for listings can only set one default sorting option.
  2. The following code will order alphabetically even if the default order is set to show featured listings first:

    [php]
    add_filter(‘geodir_posts_order_by_sort’,’_my_custom_order_by’,10,3);
    function _my_custom_order_by($orderby, $sort_by, $table){
    global $wpdb;

    if($sort_by==’is_featured_asc’){
    $orderby .= " $wpdb->posts.post_title ASC, ";
    }
    return $orderby;
    }
    [/php]

Detail page – hide ‘No Reviews’ text if there are no reviews

  1. Maybe you have a new site without a lot of reviews.
  2. The following code will hide the ‘no Reviews’ text

    [php]
    function _gd_custom_hide_no_review_text( $class ) {
    global $post;
    if ( empty( $post->rating_count ) ) {
    $class .= ‘gd-custom-no-review’;
    }
    return $class;
    }
    add_filter( ‘geodir_post_view_article_extra_class’, ‘_gd_custom_hide_no_review_text’, 10, 1 );
    [/php]

    And this short bit of CSS
    .gd-custom-no-review .geodir-entry-meta a.geodir-pcomments {
    display: none !important;
    }

Snippet to Remove GeoDirectory Scripts

Some site owner may want to optimize their site by loading GD scripts only on GD pages. The following applies only to GD core. Each Addon has additional scripts.
In GD core most of the scripts and styles are loaded via geodir_templates_scripts() and geodir_templates_styles() functions. You can use the following to skip loading of GD Core scripts.

[php]
remove_action( ‘wp_enqueue_scripts’, ‘geodir_templates_scripts’ );
remove_action( ‘wp_enqueue_scripts’, ‘geodir_templates_styles’, 8 );
[/php]

geodir_is_geodir_page() is used to identify the GD page

Here’s a Snippet that will execute only on GD Pages.
*Caution* – Snippet below is only capable of detecting GD Pages, and will not detect other WP pages where you might be using a shortcode or widget. Use with Caution!

[php]
add_action( ‘wp’, ‘wpdocs_dequeue_script’, 100 );
function wpdocs_dequeue_script() {
if (!geodir_is_geodir_page()){
remove_action(‘wp_enqueue_scripts’, ‘geodir_templates_scripts’);
remove_action(‘wp_enqueue_scripts’, ‘geodir_templates_styles’, 8);
}
}
[/php]

Common Code Snippets for Supreme Directory

See the Supreme Directory FAQ page

Showing icons instead of category links in list and grid view

Let’s change this

into this

  1. Make sure to add categories to the Listings pages, as explained here:
  2. Now add this PHP code as a new Code Snippet or to your child theme’s functions.php:

    [php]
    function _gd_custom_listing_view_category_icon( $html, $location, $cf ) {
    global $post, $_gd_custom_term_icons;

    $html_var = $cf[‘htmlvar_name’];

    if ( !empty( $post->post_type ) && $html_var == $post->post_type . ‘category’ && !empty( $post->{$html_var} ) ) {
    if ( empty( $_gd_custom_term_icons ) ) {
    $_gd_custom_term_icons = geodir_get_term_icon();
    }

    $post_taxonomy = $post->post_type . ‘category’;
    $field_value = $post->{$html_var};
    $links = array();
    $terms = array();
    $termsOrdered = array();
    if (!is_array($field_value)) {
    $field_value = explode(",", trim($field_value, ","));
    }

    $field_value = array_unique($field_value);

    if (!empty($field_value)) {
    foreach ($field_value as $term) {
    $term = trim($term);

    if ($term != ”) {
    $term = get_term_by(‘id’, $term, $html_var);
    if (is_object($term)) {
    $term_icon_url = ! empty( $_gd_custom_term_icons ) && isset( $_gd_custom_term_icons[ $term->term_id ] ) ? $_gd_custom_term_icons[ $term->term_id ] : ”;
    $term_link = ‘<a title="’ . esc_attr( $term->name ) . ‘" href="’ . esc_attr(get_term_link($term, $post_taxonomy)) . ‘"><img src="’ . $term_icon_url . ‘" alt="’ . esc_attr( $term->slug ) . ‘ icon" class="_gd-custom-cat-icon" /></a>’;
    //$term_link .= " <a href=’" . esc_attr(get_term_link($term, $post_taxonomy)) . "’>" . $term->name . "</a>";
    $links[] = $term_link;
    $terms[] = $term;
    }
    }
    }
    if (!empty($links)) {
    // order alphabetically
    asort($links);
    foreach (array_keys($links) as $key) {
    $termsOrdered[$key] = $terms[$key];
    }
    $terms = $termsOrdered;
    }
    }
    //$html_value = !empty($links) && !empty($terms) ? wp_sprintf(‘%l’, $links, (object)$terms) : ”;
    $html_value = !empty($links) ? implode(‘ ‘, $links) : ”;

    if ($html_value != ”) {
    $field_icon = geodir_field_icon_proccess($cf);
    if (strpos($field_icon, ‘http’) !== false) {
    $field_icon_af = ”;
    } else if ($field_icon == ”) {
    $field_icon_af = ”;
    } else {
    $field_icon_af = $field_icon;
    $field_icon = ”;
    }

    $html = ‘
    <div class="geodir_more_info ‘ . $cf[‘css_class’] . ‘ ‘ . $html_var . ‘" style="clear:both;"><span class="geodir-i-taxonomy geodir-i-category" style="’ . $field_icon . ‘">’ . $field_icon_af;
    $html .= (trim($cf[‘site_title’])) ? __($cf[‘site_title’], ‘geodirectory’) . ‘: ‘ : ”;
    $html .= ‘</span> ‘ . $html_value . ‘</div>

    ‘;
    }
    }

    return $html;
    }
    add_filter( ‘geodir_custom_field_output_taxonomy_key_taxonomy’, ‘_gd_custom_listing_view_category_icon’, 10, 3 );
    [/php]

  3. And add this CSS:
    [css]
    .geodir_category_list_view ._gd-custom-cat-icon {
    vertical-align: middle;
    height: 24px;
    margin: 0 5px;
    }
    [/css]

GeoDirectory does not have access to your filesystem


If you receive the above error message this will mean that things like import / export won’t work as they can’t read or write files to the system, this will also cause problems for most of our themes as they dynamically write styles files from your settings.

You should follow the above links and read the page which explains the problems http://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants

This problem is usually fixed by following the below steps:

1. Open your wp-config.php file located in the root of your website (you will need to do this via FTP or some other file manager)

2. Somewhere near the bottom of the file, usually just below the line “define(‘WP_DEBUG’, false);” try adding the line:
“define( ‘FS_METHOD’, ‘direct’ );” and then upload and refresh your admin area to see if the message has disappeared.  If the message does not disappear after a refresh try changing the line you added and specifically the ‘direct’ to the following and each time try uploading and refreshing to see if it fixes it:  “ssh2“, “ftpext“, or “ftpsockets“.

3. If #2 did not fix your problem try adding these two lines:
define( ‘FTP_USER’, ‘username’ );
define( ‘FTP_PASS’, ‘password’ );
Replacing the ‘username’ and ‘password’ with your FTP username and password, again try uploading and refreshing to see if it fixes the problem, if the problem persists repeat #2 now that you have the ftp user/pass defined.

The above three steps should fix the majority of problems, if not then please post in our support forum and a member of our support staff will assist.

 

Common styling examples

Changing the look of a featured listing Adjusting the location switcher for cities only or a one country site Hiding category legend from location map Hiding the listings count in the popular categories widget Changing the link in the map bubble
Modifying the GD Search bar Hiding the Custom Post Type (CPT) selector Removing one CPT only from the Custom Post Type (CPT) selector Hiding the “Search for” field Changing the Advanced Search cogwheel icon to text
Customizing or hiding address details Removing reviews from one CPT only Making the reCAPTCHA V2 box resize to smaller screens
Adjust Supreme Directory Featured Image Overlay Opacity

Changing the look of a featured listing

Each featured listing has the class gd-post-featured applied in listings pages.
This class can then be targeted to change the look of featured listings.
For example adding this to your CSS:

[css].gd-post-featured {background: #BDFF00 none repeat scroll 0 0;}[/css]

results in this:
featured

Adjusting the location switcher for cities only or a one country site

The default location switcher looks like this:

If you have a GeoDirectory site for one country only, you can add this to your child theme’s style.css file:

[css]#menu-item-gd-location-switcher dd {width: 50%;}[/css]

And then your switcher will look like this:

And if you have a GeoDirectory site for one region only, you can add this to your child theme’s style.css file:

[css]#menu-item-gd-location-switcher dd {width: 100%;}[/css]

And then your switcher will look like this:

Removing category legend from location map

The default location map will have a legend showing the categories in the bottom right hand corner, like this:

Legend

If you want to hide that category list hidden by default, use the code posted below. Clicking on the expand/reduce icon will then open/close it:

Then add this CSS to your child theme’s style.css file:

[css].map_category {display: none;}[/css]

To only hide it on mobile views, you can add this CSS, adjust as required:

[css]@media only screen and (max-width: 1040px) {.map_category {display: none;}}[/css]

Hiding the listings count in the popular categories widget

The popular categories widget will have show the number of listings in the categories for the selected location like this:

If you want to hide those numbers, use the code posted below:

[css]span.geodir_term_class {display: none;}[/css]

Changing the link in the map bubble

If you want to change how the main link to the listing looks, use the code below, and adjust as required:

[css].geodir-bubble_desc h4 a {background: white; padding: 3px; border: 1px solid blue;}[/css]

These pictures show before and after:
 

Modifying the GD Search bar

The GD Search bar can have a few different components depending on the addons you use, and your settings.
Learn more about the search bar here.

Hiding the Custom Post Type (CPT) selector

This CSS will hide the CPT selector everywhere:

[css].gd-search-field-cpt {display: none;}[/css]

This CSS will hide the CPT selector on all Listings (CPT and categories) pages:

[css].gd-search-input-wrapper.gd-search-field-cpt {display: none;}[/css]

This CSS will hide the CPT selector on all Listings (CPT and categories) pages:

[css].gd-search-input-wrapper.gd-search-field-cpt {display: none;}[/css]

Removing one CPT only from the Custom Post Type (CPT) selector

This CSS will hide one CPT from the CPT selector everywhere (adjust as required):

[css].search_by_post option[value=gd_event] {display: none;}[/css]

Hiding the “Search for” field

This CSS will hide the “Search for” field everywhere:

[css].gd-search-field-search {display: none;}[/css]

Full width with all search inputs inline

This CSS will allow the search bar to expand to 100% width on the screen, allowing all the items inline:

[css].geodir-loc-bar-in {max-width: 100%;}[/css]

Using Supreme Theme you can add:

[css].sd.home .featured-area .geodir-loc-bar-in {max-width: 100%;}[/css]

Changing the Advanced Search cogwheel icon to text

To change from  to  add this CSS:

[css].fa-cog:after {content: " Advanced Filter";}[/css]

Change the Advanced Search icons

Adjust this CSS for your own style; find more icons at http://fontawesome.io/cheatsheet/
To change the cog wheel:

[css]
.fa-cog:after {font-family: FontAwesome;
content: "\f1b9"; color:white; font-size: 16px;}
.fa-cog {color:transparent; font-size: 0}
[/css]

To change the search icon:

[css]
.fa-search:after {font-family: FontAwesome;
content: "\f1b9"; color:white; font-size: 16px;}
.fa-search {color:transparent; font-size: 0}
[/css]

Use font awesome icons in any text area or as links http://fontawesome.io/cheatsheet/

[html]
<i class="fa fa-facebook-square" aria-hidden="true"></i>
[/html]

Customizing or hiding address details

The display of the different levels of the address are controlled by CSS classes:

  1. span[itemprop=”streetAddress”]
  2. span[itemprop=”addressLocality”]
  3. span[itemprop=”addressRegion”]
  4. span[itemprop=”addressCountry”]
  5. span[itemprop=”postalCode”]

For example, if you only want to display the region and country, add this to your child theme’s style.css file:

[css]span[itemprop="streetAddress"],
span[itemprop="addressLocality"],
span[itemprop="postalCode"] {
display: none;
}[/css]

Hide the default phone number from logged out users

Sometimes you may want to hide some listing information from users that are not logged in. Here is an example of how you can do that with the default phone number.

[css]
.geodir_contact {display: none}
.logged-in .geodir_contact {display: initial}
[/css]

Removing reviews from one CPT only

If you only want to disable reviews for some but not all CPTs, you can use this CSS, adjust for the CPTs you want to hide. For example, replace every event with place:

[css]
.post-type-archive-gd_event .geodir_Star {display: none;}
.post-type-archive-gd_event .geodir-bubble-meta-bottom .geodir-bubble-reviews {display: none;}
.search-results .geodir-bubble-meta-bottom .geodir-bubble-reviews {display: none;}
.post-type-archive-gd_event a.geodir-pcomments {display: none !important;}
#reviewsTab {display: none !important;}
.single-gd_event dl.geodir-tab-head [data-tab="#reviews"] {display: none !important;}
.single-gd_event .sd-detail-cta .dt-btn {display: none;}
.single-gd_event .sd-ratings {display: none;}
.gd-post-gd_event .geodir-rating {display: none;}
.search-results .geodir-bubble-meta-bottom .geodir-rating {display: none;}
.gd-post-gd_event a.geodir-pcomments {display: none !important;}
[/css]

Making the reCAPTCHA V2 box resize to smaller screens

  1. You have the option to choose two different reCAPTCHA versions:
    1. reCAPTCHA V2 which requires visitors to tick a box
    2. Invisible reCAPTCHA which works in the background
  2. reCAPTCHA V2 has a fixed width as provided by Google and therefore sometimes is to wide for a small screen or another container element on your screen.
  3. To fix this you can apply the following CSS:

    [css]
    @media screen and (max-height: 575px){
    .gd-captcha {transform:scale(0.8);
    -webkit-transform:scale(0.8);transform-origin:0 0;-webkit-transform-origin:0 0;}
    }
    [/css]

  4. Adjust the @media screen settings to target the sizes you want.

Adjusting Supreme Directory theme featured image overlay opacity

    1. Supreme Directory theme has a really strong display of the featured image.
    2. Adjusting the opacity of the featured image overlay can brighten or darken your site to suit your needs
    3. Here is some CSS that you can adjust to suit your site:

      [css]
      /*location pages overlay */
      .sd-location .featured-area::before {
      opacity:0.5!important;
      }

      /* listing pages overlay */
      .single .featured-area::before {
      opacity:0.2 !important;
      }

      /* homepage overlay */
      .sd-homepage .featured-area::before {
      opacity:0.5 !important;
      }[/css]

</ol

Remove Supreme Parallax Effect

Want a little less movement on your page?
Here’s some CSS to remove the parallax effect.
Each page type has a class, so, there are different ways to target the CSS, based on your needs.

First, this CSS will remove the effect everywhere:

[css]
.featured-img {
background-position: 50% 50% !important;
}
[/css]

This CSS is targeted at the single page for a gd_place:

[css]
.single-gd_place .featured-img {
background-position: 50% 50% !important;
}
[/css]

This is targeted more widely at any CPT for a single page, but will leave the effect in place on the home page:

[css]
.single .featured-img {
background-position: 50% 50% !important;
}
[/css]

How to use GD without street addresses?

From version 1.4.6.1 of the GeoDirectory core plugin and version 1.1.6 of the Custom Post Type addon, you can use listing types that do not need an address, and that will not be displayed on the maps.

Until then (or if you do not use the Custom Post Type addon), for the maps to work correctly, every listing in your directory needed an exact location on the map.

But that does not mean that you have to display the address of the listing.

This article explains how you can hide your street addresses. This might also be hqndy if you want to add listings to the maps, but you want to hide street addresses, or country details etc.

Hiding the address on the detail page

This will apply to all your listings.

The display of the different levels of the address are controlled by CSS classes:

    1. span[itemprop=”streetAddress”]
    2. span[itemprop=”addressLocality”]
    3. span[itemprop=”addressRegion”]
    4. span[itemprop=”addressCountry”]
    5. span[itemprop=”postalCode”]

    For example, if you only want to display the region and country, add this to your child theme’s style.css file:

    [css]span[itemprop="streetAddress"],
    span[itemprop="addressLocality"],
    span[itemprop="postalCode"] {
    display: none;
    }[/css]

    Modifying the Add Listing page

    This can be applied differently for each Custom Post Type.

    Option 1: Require street input (recommended)

    Edit GD > Place Settings > Custom fields > Field:Address > Front end description.

    For example: The street address will not be shown on your listing, but your business location will be shown on the map at this address. You can also just enter the city name for a more generic display on the map. 

    Option 2: Do not require street input

    You can remove the requirement for the street address by CSS:

    [css]#geodir_post_address_row {
    display: none;
    }[/css]

    This option means that the street address will be calculated by the Google map and will be either the address where the marker is dragged, or the city name if Set Address On Map is clicked.

    Option 3: Remove all address fields (not recommended)

    You can remove all the address fields and set addresses by dragging the marker on the map only. The Google API will still fill in the complete address, but it will not be displayed on the Add Listing form.

    This option can lead to incorrect locations being added to your database, and might require some maintenance.

    Add this to your CSS for option 3:

    [css]#geodir_post_address_row,
    #geodir_post_country_row,
    #geodir_post_region_row,
    #geodir_post_city_row,
    #post_set_address_button,
    #geodir_post_zip_row {
    display: none
    }[/css]

    Custom field examples

    On this page:

    Special icons

    The icons you see above are created using custom fields and some CSS styling.

    is created using a checkbox custom field and an image background.
    is created using a select custom field.
    is created using a text custom field.
    is created using a checkbox custom field and a FontAwesome background.

    Creating the custom fields

    The above examples all use these settings:

    1. Is active: Yes
    2. Show on listing page: Yes
    3. Complete any other fields as you wish
    Custom field settings:
    1. Choose a Checkbox field
    2. HTML variable name: pool (example only – needs to be a unique name)
    Custom field settings:
    1. Choose a Select field
    2. HTML variable name: range (example only – needs to be a unique name)
    3. Option values: Cheap/$,Modest/$$,Expensive/$$$,Rip-Off/$$$$ 
      1. Example only
      2. The text before the / is the choice your users will see, and the text after the / is the text displayed on your site.
    Custom field settings:
    1. Choose a Text field
    2. Field data type: NUMBER
    3. HTML variable name: discount (example only – needs to be a unique name)
    Custom field settings:
    1. Choose a Checkbox field
    2. HTML variable name: parking (example only – needs to be a unique name)

    Styling your custom field output

    To style the result of your custom fields on your website, add the following to your child theme’s style.css file:

    [css].geodir-entry-meta {clear: both;}[/css]

    Then also add the relevant codes below:

    1. Examples only.
    2. Adjust to suit your site etc.
    3. Every custom field automatically is asigned a CSS class like geo_HTML variable name
    CSS code:

    [css]
    /* Pool label style */
    .geodir_pool {
    float: left;
    display: inline;
    clear:none !important;
    margin: 3px 3px 3px 0px;
    border-radius: 5px;
    border: 1px solid blue;
    background: white;
    background-image: url("/img/pool.png");
    background-repeat: no-repeat;
    color: transparent;
    font-weight: 400;
    width: 38px;
    text-align: center;
    background-position: 3px;
    }
    .geodir_pool .geodir-i-checkbox {
    display: none;
    }
    [/css]

    CSS code:

    [css]/* Range label style */
    .geodir_range {
    float: left;
    display: inline;
    clear:none !important;
    margin: 3px 3px 3px 0px;
    border-radius: 5px;
    background: none repeat scroll 0 0 green;
    color: #fff;
    font-weight: 400;
    width: 40px;
    text-align: center;
    padding: 6px 0 !important;
    }
    .geodir_range .geodir-i-select {
    display: none;
    }[/css]

    CSS code:

    [css]/* Discount label style */
    .geodir_discount:after {
    content: "%";
    }
    .geodir-i-text {
    display: none;
    }
    .geodir_discount {
    background: none repeat scroll 0 0 red;
    border-radius: 5px;
    color: #fff;
    font-weight: bold;
    text-align: center;
    padding: 6px 0 !important;
    width: 40px;
    float: left;
    display: inline;
    clear:none!important;
    margin: 3px 3px 3px 0px;
    }[/css]

    CSS code:
    1. This button uses FontAwesome to create the images.
    2. If you look at the code below, you’ll see content: “\f1b9”
    3. That is the FontAwesome code for the image  of the car.
    4. To find the CSS code for any FontAwesome “letter”, have a look at the FontAwesome cheatsheet.
    5. There you will find all FontAwesome “letters”, and to get the CSS code, remove &#x from the beginning of the code, and ; from the end of the code, and add a \ in front.
    6. For example the CSS code for fa-car [&#xf1b9;] is \f1b9

    [css]/* Parking label style */
    .geodir_parking {
    float: left;
    display: inline;
    clear:none !important;
    margin: 3px 3px 3px 0px;
    border-radius: 5px;
    border: 1px solid #990099;
    background: white;
    color: transparent;
    width: 38px;
    text-align: center;
    background-position: 3px;
    height: 29px;
    }
    .geodir_parking:before {
    font-family: FontAwesome;
    content: "\f1b9";
    color: #990099;
    font-size: 18px;
    padding-left: 8px;
    }
    .geodir_parking .geodir-i-checkbox {
    display: none;
    }[/css]

    Adding customer logos

    Creating the custom field

    1. Create a File Upload custom field
    2. For the HTML variable name, the below example uses logo (example only – needs to be a unique name)
    3. For this example we have added it to the sidebar

    Styling your custom field output

    If you now upload a file as a logo, it will look like this, so we will need to add some CSS to make it look a bit better:

    Removing “Logo:”

    Adding this CSS will remove the label:

    [css].geodir_logo .geodir-i-select span { display: none !important;}[/css]

    Adding this CSS will resize the logo:

    [css].geodir_logo .geodir-custom-post-gallery .geodir_thumbnail {background-size: initial;}
    .geodir_logo .geodir-custom-post-gallery {width: 100% !important;}
    .geodir_logo .geodir-custom-post-gallery {
    border: none;
    margin-bottom: -10px;
    margin-top: -10px;
    }[/css]

    And this is the result:

    Known issues

    This page lists some conflicts with other plugins or themes.

    Note that the below problems were correct at the time of writing, and that either GD or the third party plugins or themes may have been modified in the meantime to correct the problem.

    Let us know if anything on this page is no longer valid. Thank you.

     

    Plugins

    Themes

    Other

    Cache Plugins

    Plugins

    Advanced Access Manager

    1. This plugin is not compatible with the GD Search functions without the following setting:
    2. AAM > Settings > Content Settings > Check Post Visibility – UNCHECK this setting

    Advanced Custom Fields

    1. Hide WP Custom Fields – This plugin will hide the normal WordPress custom fields in the backend editor for posts. Some themes like Supreme make use of WP custom fields, so, disable the plugin to view and edit the custom fields.
    2. Incompatibility – Geodirectory does not have any integration with ACF for listing custom fields. Adding fields through ACF will not add fields to all GD listings; use GD custom fields instead.

    BuddyPress Docs

    1. This plugin is not compatible with the GD Search functions.

    BuddyBoss Wall

    1. This plugin is not compatible with the GD Search functions.

    BuddyPress Global Search

    1. This plugin is not compatible with the GD Search functions.

    Edit Flow

    1. Edit Flow adds a custom taxonomy (category) to all post type following_user and adding the author automatically to the post as a new category.
    2. Edit Flow also partially breaks the dashboard for GD posts.

    EventOn

    1. EventOn breaks the GD Add Listing forms.

    Express Curate

    1. This plugin creates duplicate WP posts of any new GD listing.

    Hide My WP

    1. This plugin rewrites the path of your folders and files using .htaccess.
    2. Your searches etc will no longer work.

    Loco Translate

    1. Loco Translate is not compatible with Geodirectory. Only WPML is compatible with Geodirectory for multilingual sites.
    2. Geodirectory translation should be done with PoEdit as described here.
    3. Local Translate will overwrite .PO files placed at wp-content/languages/plugins
    4. Loco Translate will automatically create language files with incorrect names so that the files are not loaded.
    5. Loco Translate does not recognize all GD language strings, so you will not be able to translate everything.
    6. Check the file names of the .PO files to make sure they are correct, see Translating Addons for the correct file names.

    TranslatePresss

    1. Stores additional copies of strings found in language files.
    2. Can result in changes to PO files ‘not working’ because TranslatePress versions will override PO string values.
    3. TranslatePress must be de-activated to diagnose issues with PO file strings.
    4. Only WPML is fully compatible with GD.

    Polylang

    1. Only WPML is fully compatible with GD.

    Relevanssi

    1. This plugin is not compatible with the GD Search functions.

    Scripts n Styles

    1. This plugin introduces a jQuery chosen conflict that can cause GD forms to not function.
    2. The plugin can cause isues on any add/edit post pages or anywhere in the backend..

    Scroll To Anchor

    1. This plugin breaks the menus of the Supreme theme in mobile view.

    Sidebar & Widget Manager for WordPress

    1. If your drop-down menus in GD admin area don’t work, then this premium plugin from OTWthemes might be the reason.
    2. Reported by a user on 3 August 2015.

    Simple Custom CSS and JS

    1. Breaks JS.

    Theme My Login

    1. This plugin is not compatible with the GD Search functions.

    The SEO Framework

    1. The SEO Framework breaks GeoDirectory queries, we suggest to use Yoast that is 100% compatible with GD, or GD’s Titles and Meta options.

    Ubermenu

    1. This plugin calls the Google Map API (and also fontawesome), just like GD does.
      The result is that your page tries to load the Google API twice.
      Therefore your maps will not work.
    2. You can fix this by disabling both the Google Map API  and fontawesome in the Ubermenu settings > General Settings > Assets.

    WP Places

    1. This plugin causes backend editor google map to fail to load.
    2. The plugin loads another copy of the GMaps API causing all maps to fail on the page.
    3. The plugin loads on every backend post edit page, even if the post types are disabled.

    WP-SpamShield

    1. This plugin stops your GD registration and login process.
    2. This plugin is not compatible with the WPaffiliate plugin required with the GD WPaffiliate Integration addon.  .
    3. We suggest using GD Recaptcha.

    Yoast SEO

    1. Specific settings for redirects may conflict with GD “Near” Search.
    2. The Yoast setting comes with a warning: “May cause conflicts!”.
    3. Check “No Redirect” at SEO > Advanced > Permalinks > “Redirect ugly URLs to clean permalinks”.
    4. “Disable author archives” will make the GD profile pages disappear.
    5. Yoast sitemaps regenerate automatically. If changes are made to Permalinks it may take some time for Yoast to regenerate the pages with the new URL structure.

    Themes

    Braxton

    1. You will not be able to add some GD widgets to your pages.

    Langwitch

    1. The multilingual features do not work with custom post types like GD listings.

    Sky

    1. This theme replaces some GD options with their own, for example the sorting options for the Place Settings.

    Kleo

    1. Broken URLs – Past versions of Kleo have included a filter for wp_redirect that breaks redirects across the site. If you are experiencing that issue, you should contact Kleo support and reference this information. Past fix was to comment lines 99-103 in file kleo\lib\importer\import.php (see the following code)
      [php]
      if ( defined( ‘DOING_AJAX’ ) && DOING_AJAX ) {
      add_filter( ‘wp_redirect’, function () {
      return false;
      } );
      }[/php]

    AviaBuilder

    AviaBuilder is included with several popular themes including Enfold.

    1. Unable to edit/save listing in frontend or backend – See this topic for a fix: https://wpgeodirectory.com/support/topic/listing-description-not-visible-after-saving/page/2/#post-420413
    2. Maps not loading – See https://wpgeodirectory.com/support/topic/unable-to-make-changes-to-records-places-even-as-admin/#post-436922

    Thrive

    1. The builder strips inline CSS from the header.
    2. Add CSS to GD > Scripts > Footer instead of header

    Other

    Flexslider

    1. You can only use one Flexslider on a page, and because GD and some other plugins and themes use the same Flexslider, there often is a conflict resulting in only one of the two flexsliders on the page working.
    2. You can add this line to your theme functions.php and it should solve it for you:

      [php]wp_enqueue_script(‘geodirectory-jquery-flexslider-js’);[/php]

    Cache Plugins

    General Compatibility with Cache Plugins

    1. GeoDirectory is only fully compatible with GD Booster and WP Super Cache.
    2. Please see settings for Autoptimize here
    3. If you use WP Super Cache, you need to review the settings here.
    4. If you use GD Booster, it is recommended that you do not use any other cache plugins with it (including WP Super Cache).

    Image Opitmizers

    GeoDirectory is designed with several optimizations for images. Listings images are stored outside the media library to keep the media library uncluttered. Therefore, some plugins that claim to optimize images are not compatible with GD and can lead to unexpected behavior. Here are a couple of the ones we have heard of so far.

    1. WP Smushit – not compatible, results in images not being displayed
    2. EWWW Image Optimizer – not compatible, may result in blank pages for Add listing process

    Bluehost

    1. Bluehost plugin caching is incompative with GD.

    Jetpack

    1. GeoDirectory listings are not available to be indexed by Jetpack Search at Admin > Jetpack > Settings > Traffic > Search
    2. ‘Speed up images and photos’ setting will cause images to ‘disappear’, with or without GD Booster.
    3. ‘Social networks sharing’ may cause duplicate graph metadata and create difficulty with sharing to social networks.
    4. ‘Widget Visibility’ jetpack plugin can interfere with adding some GD widgets [reported 14 September 2015].
    5. Automattic adds new features to Jetpack regularly; report new issues as you find them.

    Jetpack – Comments

    1. When enabling Jetpack Comments, your comments on your listings will not be counted by GD.
    2. Do NOT enable Show a ‘follow comments’ option in the comment form at Settings > Discussion for the Jetpack settings.
    3. Do NOT enable GD Recaptcha for comments if you are using Jetpack comments with social login.

    Cloudflare Rocket Loader

    1. Cloudflare Rocket Loader is not compatible with GD.
    2. The only compatible tool to minify and concatenate scripts and css files is GD Booster.
    3. In some cases may be the cause of Google Map’s failure to load.

    Scripts to Footer

    1. Causes JQuery errors visible in console, resulting in breaking search and maps.

    W3Cache

    1. GD and GD Booster are not compatible with W3Cache.

    How to build your own theme compatibility plugin

    The GD core plugin now has a theme compatibility section where you can build any special settings for any theme.
    The information below is not required anymore to make your theme compatible, but still contains useful information, so we have not deleted it.

    GeoDirectory will integrate nicely into many themes, but there are occasions where things appear to be out of place. This is usually because your theme has declared extra content areas which GD doesn’t recognise, or because your theme’s css rules are overriding those declared by GeoDirectory.

    The best way to address these issues is to build a compatibility plugin to modify the behaviour of GeoDirectory and force it to output content into your desired areas.

    This isn’t as scary as it sounds, so let’s walk through the process…

    Requirements for this project

    For this project you will need a text editor to write your code and an FTP program to upload the files to your website. It doesn’t matter which programs you use, but my preferences are Sublime Text and FileZilla

    Step 1 – Creating the plugin

    All the files you will be creating will be stored in a folder, so let’s create that first. For the purpose of this tutorial i’ve named the folder my-gd-plugin. Now open up your favourite text editor and create a new file within your new folder called mygdplugin.php (you can use your own name, but make sure to save it as a .php file)

    Add the following to your new file:

    https://gist.github.com/PoshJohn/fe8d902f9e0097e5a3d7

    Congratulations – you’ve just created your first plugin! Now let’s make it actually do something…

    Step 2 – Adding & Removing Actions

    What we will be trying to do here is remove the actions that GeoDirectory uses to output the HTML wrappers of the main content and sidebar areas, and replace them with new ones we create.

    GeoDirectory template files are a series of action hooks which run functions. We can change the behaviour of the plugin’s output by “unhooking” functions from their positions, and replacing them with our own functions.

    Consider the steps necessary when you make yourself a coffee:

    1. Add coffee powder to cup
    2. Add boiling water to cup
    3. Add milk to cup
    4. Add sugar to cup
    5. Stir.

    What if you wanted a black coffee? You would remove action number 3. If you fancied a hot chocolate you would remove action 1 and add a new action in it’s place (1. Add chocolate powder to cup)

    This is exactly what we are going to be doing with our plugin.

    Depending on the complexity of your theme, there may be many actions you need to look at. For the purposes of this tutorial we will look at the main three elements:

    1. The outer wrapper which contains both the content and sidebar areas
    2. The wrapper which contains the content area
    3. The wrapper which contains the sidebar

    Here are the actions we will be replacing.

    https://gist.github.com/PoshJohn/37460fa990f836bb768a

    So what is happening here? Let’s take the first remove/add example:

    We are saying in hook position geodir_wrapper_open remove the function geodir_action_wrapper_open and replace it with a new function called geodir_mytheme_action_wrapper_open

    This means that every time a GeoDirectory template gets to that hook position, it will run our function instead of the in-built function. You can give your functions any name you like, as long as you use the same names in the next step.
    I typically use the original function name and add the name of my theme into it
    e.g. : geodir_action_wrapper_open becomes geodir_mytheme_action_wrapper_open

    Step 3 – Adding Our New Functions

    At this stage our plugin won’t work because we are telling GeoDirectory to run functions that don’t exist – so let’s start creating them!

    Taking the first example again, let’s build the function to replace the output wrapper of the main content/sidebar area.
    We told GeoDirectory to run a function called geodir_mytheme_action_wrapper_open, so let’s create that function now.

    https://gist.github.com/PoshJohn/f32f2c7f7414f3db05d9

    We simply need to continue that process for our remaining functions. Here is the finished plugin which replaces the output wrappers of the 3 main elements:

    https://gist.github.com/PoshJohn/e83a32f3cfbcec4b91d4

    Step 4 – Styling The Elements

    Since you will be creating this plugin to work with a specific theme, it doesn’t really make sense to load a new stylesheet. Styles therefore will be added to your theme’s style.css file as usual. For helpful tips on styling, take a look at this post on customising your style.

    Important Things To Note

    When we replace a function, it is important to note the structure of the original function. Did you notice the numbers at the end of the actions? The first number is the priority of the action and the second is the number of arguments passed. These should stay the same as the original function in most cases.

    For more information on actions & functions, a great place to start is the WordPress Codex:

    Conclusion

    Congratulations on building your first GeoDirectory compatibility plugin!

    There are many other functions that can be overridden, plus filters that can be utilised to modify the output of existing functions.

    For working examples of these, you can download one of the existing compatibility plugins.

    Hopefully the information provided in this tutorial will enable you to seamlessly integrate GeoDirectory into your theme. If however you are overwhelmed and would rather have someone else create the plugin for you, I am available for a small fee. Please feel free to contact me for a quote.

    Customizing your style

    This article explains how you can create new CSS rules to change the style of your site.

    Most browsers have a built-in code inspector, for example FireFox has Firebug, Internet Explorer and Chrome have Developer Tools.

    For the example below, we will use Chrome’s Developer Tools to change the footer background color on the GeoDirectory Demo.

    1. Open the Chrome browser to the web page where we want to change the style of an element.
    2. Right click on the footer area element we want to change [Step 1 in the image below – we are right clicking on the footer].
    3. From the pop-up menu, choose Inspect element. If the code inspector is not open yet, it will open.
    4. If the element is not highlighted yet, we click on it to make sure it is [Step 2 and 3 – highlight the footer style].
    5. We can continue to select ‘Inspect’ until the element we want is highlighted in the code[Step 4 – in this case it shows that the footer class has a background color specified].
    6. The code inspector will also show you in which file you can find the code [Step 5].
      Turn off GD Booster before checking your CSS.
    7. The CSS code is displayed, and we click on the rule to change the background color; double click starts the editing. In this case we will change the background color to red [Step 6 in the second image].
    8. If the CSS code is correct, the web page will adjust to show your change [The footer is now red].
    9. Use the mouse to highlight the CSS code and copy it to your clipboard; proceed to add it to your site. You can add custom CSS to GeoDirectory at GeoDirectory > Design > Scripts > CSS Custom Code, or use anotherplugin or even add that code to the stylesheet of your child theme at WP Admin > Appearance > Editor and locate style.css in your child theme.
    10. Add the code .footer {background-color:red;}, and save. That will update your site.

    Hints

    • You can add “!important” if your style rule doesn’t seem to have an effect. ‘!important’ will raise the priority of the rule if it conflicts with other rules. Example:
      [css]
      .footer {background-color:red !important;}
      [/css]
    • The code inspector will provide you with valid auto-complete suggestions as you type. Choose one, or two, and try them out until you become comfortable with the editor.
    • See it in action on Youtbe by WPBeginner.
    • Set a reminder on your calendar to backup your custom styles by copy/paste into a file every month. If you need to uninstall GD temporarily, don’t forget to make a copy of the Scripts you store in this location.

    How to add CSS, PHP, and Javascript Snippets to your site

    • CSS – Add CSS to the GeoDirectory Design Admin Panel called Scripts. Navigate to YourSite > GeoDirectory > Design > Scripts > Custom Style CSS Code
    • PHP – Add PHP Snippets to your site with the Code Snippets plugin, a Very lightweight plugin that makes it easy to manage your custom code, and keeps it all in one place even if your plugins or themes get updated. There is a special case for ‘constants’, values that apply sitewide. These are PHP Snippets that start with ‘define’ like define(‘SD_DEFAULT_FEATURED_IMAGE’, “http://yourdomain.com/images/featured.jpg”). Constants should be added to your site’s wp-config.php file.
    • Javascript – You may never need this, but if you do need to add a Javascript snippet, add it to YourSite > GeoDirectory > Design > Scripts > Header Script Code or Footer Script Code, depending on the instructions you receive with the snippet.

    Useful resources

    Using child themes http://codex.wordpress.org/Child_Themes
    CSS tutorial http://www.w3schools.com/css/
    Using FireFox Page Inspector https://developer.mozilla.org/en-US/docs/Tools/Page_Inspector
    Using Chrome Dev Tools https://developer.chrome.com/devtools/docs/elements-styles
    Using Internet Explorer F12 developer tools http://msdn.microsoft.com/library/ie/bg182326
    SiteOrigin CSS Plugin https://wordpress.org/plugins/so-css/

    Redirecting the login or registration page

     

    On this page we’ll explain how to integrate your GeoDirectory with some other plugins that use the WordPress user accounts.

    Introduction

    1. By default GD will add its own registration and login page.
    2. But you may want to redirect either the login and/or registration links to other pages, for example because you are using a membershipp plugin.
    3. You can add the following code snippets to your child theme’s functions.php or use the code snippets plugin.

    1. Redirecting your login

    [php]add_filter(‘geodir_login_url’,’change_geodir_login_url’,10,3);
    function change_geodir_login_url($login_url,$args,$gd_page_id){
    //change the url to whatever you want.
    $login_url = ‘http://your-site.com/my-login-page’;
    return $login_url;
    }[/php]

    2. Redirecting your registration

    [php]add_filter(‘geodir_login_url’,’_my_geodir_login_url’,10,3);
    function _my_geodir_login_url($login_url,$args,$gd_page_id){
    if(isset($args[‘signup’])){
    //change the url to whatever you want.
    $login_url = ‘http://your-site.com/my-rego-page’;
    }
    return $login_url;
    }[/php]

    3. Adjust for your particular integration

    In the code above you’ll see we are redirecting geodir_signup to /wp-login.php

    The page it is redirecting to might have to be adjusted for your situation.

    WooCommerce

    A standard installation of WooCommerce creates a shopper’s account page at /my-account.

    You would change the above code to

    [php]$login_url = ‘http://your-site.com/my-account’;[/php]

    bbPress, s2Member etc

    The code above will work to by-pass GD’s registration and login process for all plugins that use the standard WP login, like:

    • bbPress
    • s2Member

    Customizing GeoDirectory templates

    Your GeoDirectory site uses a number of special templates to create your map pages, category pages, detail pages etc.

    You can find the default templates at /wp-content/plugins/geodirectory/geodirectory-templates.

    We provide many hooks and filters that can provide lots of customization options without having to replace templates (this is the preferred way) but If you want to customize them in any way, just follow these steps:

    1. The default templates at /wp-content/plugins/geodirectory/geodirectory-templates.
    2. Navigate to your child theme.
    3. Create a folder in your active child theme folder called geodirectory. 
    4. Find the template you want to customize.
    5. And copy that template to the geodirectory folder in your active child theme.
    6. You can then change the original templates and insert any code needed to adapt the templates for your site or theme.
    7. By creating a copy of the template to your child theme, you will preserve all your changes when the plugin needs upgrading.

     

    The two files login_frm.php and reg_frm.php are called in the template geodir-signup.php, you can replace this template but there are easier ways , adding the code below to your child theme functions.php will then allow you to replace those two files as the same way as all the others via the above method.