GeoDirectory Alphabetical Order

User
display geoDirectory search result in to alphabrtical order
Assistant
To display GeoDirectory search results in alphabetical order in WordPress, follow these steps:

### 1. **Use a Code Snippet**
You can modify the query used by GeoDirectory using the `geodir_filter_widget_listings_args` or `geodir_filter_archive_args` filter. Add the following code to your theme's `functions.php` file or a custom plugin:

function custom_geodir_alphabetical_order($query_args) {
    if (is_search() || geodir_is_page('search')) { 
        $query_args['orderby'] = 'title'; 
        $query_args['order'] = 'ASC'; 
    }
    return $query_args;
}
add_filter('geodir_filter_widget_listings_args', 'custom_geodir_alphabetical_order');
add_filter('geodir_filter_archive_args', 'custom_geodir_alphabetical_order');

### 2. **Explanation of the Code**
– `is_search()`: Checks if the current page is a search results page.
– `geodir_is_page('search')`: Ensures that this applies to GeoDirectory search results.
– `orderby`: Orders the results by the title of the posts (default is post title).
– `order`: Sets the order to ascending (`ASC`).

### 3. **Test the Results**
– Perform a search using GeoDirectory and confirm that the results are ordered alphabetically by the title.

### 4. **Adjust for Specific Widgets or Pages (Optional)**
If you need this for specific widgets or templates only, you can further customize the conditions in the function. For example, add checks for specific widget IDs or template files.

Let me know if you encounter any issues!

User
Display map also in search page
Assistant
To display a GeoDirectory map on the search results page, you can follow these steps:

### **Option 1: Enable GeoDirectory Map on the Search Page via Settings**
1. Go to your WordPress Dashboard.
2. Navigate to **GeoDirectory > Settings > General**.
3. Locate the **Map Settings** section.
4. Ensure the option **Show Map on Search Page** is enabled (or similar, depending on your version).
5. Save the changes.

### **Option 2: Add the Map Manually to the Search Page Template**
If the map is not displaying, you can add it manually to the search page template.

1. Locate your theme's search results template. It may be named something like `search.php`, `archive.php`, or a GeoDirectory-specific template like `archive-geodir.php`.
2. Add the GeoDirectory map shortcode or function.

#### Using Shortcode:
Add the following shortcode where you want the map to appear:

<?php echo do_shortcode('[gd_map]'); ?>

#### Using GeoDirectory Map Function:
If you're customizing a PHP template, use this function:

if (function_exists('geodir_show_map')) {
    echo geodir_show_map();
}

### **Option 3: Display the Map via a Widget**
You can also use the GeoDirectory map widget to add a map to the sidebar or a widgetized area.

1. Go to **Appearance > Widgets** in your WordPress Dashboard.
2. Look for a widget named **GeoDirectory Map**.
3. Drag it to the desired widget area (e.g., "Search Page Sidebar").
4. Configure the widget settings and save.

### **Option 4: Customize the Page with a Page Builder**
If you're using a page builder (e.g., Elementor, Divi, or WPBakery), you can:
1. Add a new section or widget to the search results page layout.
2. Insert the GeoDirectory map shortcode `[gd_map]` or use the builder’s GeoDirectory map module (if available).

### **Additional Notes:**
– If the map does not display after following these steps, ensure that GeoDirectory's map scripts are being loaded. Check for conflicts with other plugins or themes.
– If using a caching plugin, clear the cache to ensure changes take effect.
– Customize the map settings (like zoom level or filters) in **GeoDirectory > Settings > Map Settings**.

Let me know if you need more help!

Leave a Comment

Your email address will not be published. Required fields are marked *