Skip to content

Common changes with a few lines of code (Recipes)

Reign GeoDirectory Addon overviewPremiumGet Reign GeoDirectory Addon →

Also called: code snippets, functions.php recipes, child theme examples, directory code, GeoDirectory add-on hooks examples

Each recipe below makes one change that site owners often ask for. Copy the snippet, paste it into your child theme, and save. Every snippet was tested with Reign GeoDirectory Addon 2.5.0, GeoDirectory, BuddyPress, Reign 8.1.0 and the official Reign child theme.

  • Install and activate the Reign child theme. Changes in the parent theme are lost when Reign updates.
  • Open the child theme’s functions.php. Paste each snippet at the very end of the file.
  • Edit files through your host’s file manager or SFTP. If a snippet has a typo, the site can show an error. You can then fix the file the same way.

Try each change on a staging copy first if your site is busy.

Rename the Places tab and show more listings

Section titled “Rename the Places tab and show more listings”

Each member profile has a Places tab with the member’s listings, six per page. This snippet renames the tab to “Listings” and shows 12 per page.

add_filter( 'reign_geodir_places_tab_label', function () {
return 'Listings';
} );
add_filter( 'reign_geodir_places_per_page', function () {
return 12;
} );

The tab address stays /places/. To change it too, use reign_geodir_places_tab_slug the same way. See Templates and hooks.

You’ll know it worked when member profiles show a “Listings” tab. A member with more than six listings then shows up to 12 on the first page.

When a member publishes a listing, the activity feed posts a line about it. By default it reads: A new location Harbour Cafe was added by Alex Rivera.

This snippet changes it to: Alex Rivera just listed Harbour Cafe. Take a look!

add_filter( 'reign_geodir_add_location_activity_filter', function ( $text, $link, $author_id ) {
return sprintf( '%1$s just listed %2$s. Take a look!', bp_core_get_userlink( $author_id ), $link );
}, 10, 3 );

$link is a ready link to the listing. This filter is for BuddyPress and BuddyBoss. On PeepSo, use reign_peepso_geodir_add_location_activity_filter.

The new text applies to listings published after you add the snippet. Posts already in the feed keep their words.

You’ll know it worked when you publish a new listing and its feed post uses your words.

Change one template: the message for a member with no listings

Section titled “Change one template: the message for a member with no listings”

When a member has no published listings, visitors to their Places tab read: Chloe Martin has not published any Places yet.

This override changes those words. Use the same steps for any file in the add-on’s templates/ folder.

  1. Copy reign-geodirectory/templates/places/empty.php.

  2. Paste it into your child theme at reign-child-theme/geodirectory/reign/places/empty.php. Create the geodirectory, reign and places folders if they are missing.

  3. In your copy, find this line.

    echo esc_html( sprintf( __( '%1$s has not published any %2$s yet.', 'reign-geodirectory' ), $name, $label ) );
  4. Change it to this line.

    echo esc_html( sprintf( __( 'No %2$s from %1$s yet. Check back soon.', 'reign-child' ), $name, $label ) );
  5. Save the file.

You’ll know it worked when a visitor opens the Places tab of a member with no listings and reads your new message. The member still sees their own message, from the if ( $own ) part of the file.

Keep the @version 2.5.0 line in your copy. After an add-on update, the settings screen lists your copy under Outdated template overrides if the original changed. Then compare your copy with the new file. See Templates and hooks.

Open functions.php again through your host’s file manager or SFTP. Remove the snippet you just added and save. The site comes back straight away.

Yes. The PHP snippets work the same in a snippets plugin. The template recipe needs the child theme, because it is a file.

Every hook the add-on offers is in Templates and hooks.