preloader

GeoDirectory Schema Markup: How to Customize It for Your Niche

GeoDirectory generates LocalBusiness structured data for every listing based on the category’s schema type setting. This automatic schema is what helps listing pages appear in Google’s local search results. For niche directories, configuring the right schema type per category and extending it with niche-specific properties significantly improves how Google understands and displays your listings.

Setting Schema Types Per Category

Go to GeoDirectory -> Listings -> Categories and edit each category. Find the Schema Type field and select the most specific type for that category. Using Restaurant instead of the generic FoodEstablishment or LocalBusiness gives Google more precise information about the listing type, which can improve rich result eligibility. Common schema types by niche:

  • Food: Restaurant, Bakery, CafeOrCoffeeShop, BarOrPub, FastFoodRestaurant
  • Accommodation: Hotel, BedAndBreakfast, Hostel, Motel, Resort
  • Medical: Dentist, Physician, MedicalClinic, Optician, Hospital
  • Legal and finance: LawFirm, AccountingService, FinancialService, InsuranceAgency
  • Trade services: Plumber, Electrician, AutoRepair, HairSalon, CleaningService
  • Fitness: FitnessCenter, SportsClub, Gym, YogaStudio

Extending Schema With Custom Properties

For schema properties that GeoDirectory does not map automatically, extend the output with the geodir_schema_json_ld filter. This example adds cuisine type and price range to Restaurant listings:

add_filter('geodir_schema_json_ld', function($schema, $post) {
    if (empty($schema) || !isset($schema['@type'])) {
        return $schema;
    }

    if ($schema['@type'] === 'Restaurant') {
        $cuisine = get_post_meta($post->ID, 'cuisine_type', true);
        if ($cuisine) {
            $schema['servesCuisine'] = $cuisine;
        }

        $price_range = get_post_meta($post->ID, 'price_range', true);
        if ($price_range) {
            $schema['priceRange'] = $price_range;
        }

        $menu_url = get_post_meta($post->ID, 'menu_url', true);
        if ($menu_url) {
            $schema['hasMenu'] = esc_url($menu_url);
        }
    }

    return $schema;
}, 10, 2);

Need a developer to implement this? Describe your project and get a free estimate.

Adding Review Schema

GeoDirectory handles aggregateRating schema when a listing has reviews. To include individual review entries in the schema output:

add_filter('geodir_schema_json_ld', function($schema, $post) {
    if (empty($schema) || !isset($schema['aggregateRating'])) {
        return $schema;
    }

    $reviews = get_comments([
        'post_id' => $post->ID,
        'status'  => 'approve',
        'number'  => 3,
    ]);

    if ($reviews) {
        $schema['review'] = array_map(function($r) {
            return [
                '@type'        => 'Review',
                'reviewRating' => [
                    '@type'       => 'Rating',
                    'ratingValue' => get_comment_meta($r->comment_ID, 'geodir_overallrating', true),
                    'bestRating'  => '5',
                ],
                'author'     => ['@type' => 'Person', 'name' => $r->comment_author],
                'reviewBody' => $r->comment_content,
            ];
        }, $reviews);
    }

    return $schema;
}, 10, 2);

Validating Your Schema Output

After implementing customisations, validate using Google’s Rich Results Test at search.google.com/test/rich-results. Enter a listing page URL and verify the structured data parses correctly. Fix both errors (which prevent rich results) and warnings (which reduce rich result eligibility). Common issues include missing required properties for the specific schema type, invalid URL formats, and incorrectly formatted opening hours strings.

The most important properties for local business rich results are name, address (with streetAddress, addressLocality, addressCountry), telephone, url, and aggregateRating. Without these, the schema is technically valid but unlikely to generate enhanced search results.

Business Hours Schema

GeoDirectory maps its built-in business hours field to openingHoursSpecification schema automatically when hours are entered in GeoDirectory’s format. Verify this is working by checking the JSON-LD output in your page source – search for “openingHoursSpecification” after viewing a listing with hours entered. If the hours are not appearing in the schema, they may be stored in a custom field rather than GeoDirectory’s built-in hours field.

For custom hours fields, map them to schema manually in the filter:

add_filter('geodir_schema_json_ld', function($schema, $post) {
    if (isset($schema['openingHoursSpecification'])) {
        return $schema; // already set by GeoDirectory
    }

    $hours = get_post_meta($post->ID, 'custom_business_hours', true);
    if ($hours) {
        // Format: "Mo-Fr 09:00-17:00" or array of such strings
        $schema['openingHours'] = $hours;
    }
    return $schema;
}, 10, 2);

Multiple Schema Types for a Single Listing

Schema.org allows entities to have multiple types. A business that is both a restaurant and a bar can be typed as [“Restaurant”, “BarOrPub”]. Use this for listings that genuinely fit multiple categories:

add_filter('geodir_schema_json_ld', function($schema, $post) {
    $secondary_type = get_post_meta($post->ID, 'secondary_schema_type', true);

    if ($secondary_type && isset($schema['@type'])) {
        $schema['@type'] = [$schema['@type'], $secondary_type];
    }

    return $schema;
}, 10, 2);

Store the secondary type as a custom GeoDirectory field where listing owners or admins select the additional type. Only use multiple types when they genuinely apply – a restaurant is not also a Hotel just because it has a bar.

Testing and Monitoring Schema

After implementing schema customisations, validate using Google’s Rich Results Test for individual pages, and use Google Search Console’s Rich Results report to monitor which listing pages are generating enhanced results across your whole directory. Search Console shows which listings have valid schema, which have errors, and which are eligible for rich results but not yet appearing. This data tells you whether your schema customisation is working at scale, not just for the specific URLs you tested manually.

Keep Reading

Previous Post How to Override Directorist Templates in Your Child Theme Next Post How to Build a Restaurant Directory With GeoDirectory: From Setup to Launch

Need Help With Your WordPress Site?

If you need help with WordPress fixes, plugin issues, theme customization, or development work, feel free to get in touch.

Get a Free Estimate