{CODICTS} Snippets is now available

MyListing Auto Related Listings

The {CODICTS} MyListing Auto Related Listings plugin automates the process of populating Related Listing fields when a listing is created or updated. Instead of requiring listing owners to manually search for and select related listings one by one, the plugin automatically discovers and attaches matching listings based on the filters already configured on the Related Listing field in the MyListing listing type editor.

Installation & Activation

Start by downloading the plugin from the Downloads page on your dashboard on the CoDicts website.

After downloading, install and activate the plugin in WordPress by navigating to “Plugins” > “Add New” > “Upload Plugin” and selecting the downloaded zip file. Click “Install Now” and then “Activate”.

Once activated, the plugin works immediately with zero configuration in its default auto-fill mode. It reads the Related Listing field’s filters directly from the MyListing listing type definition. Optionally, navigate to “Auto Related Listings” in the WordPress admin sidebar to adjust settings.


Key Features

FeatureDescription
Zero-Configuration Auto-FillWorks out of the box by reading the Related Listing field’s existing configuration (listing type filter, author restriction, status restriction) directly from the listing type definition.
Two Operating ModesAuto-Fill mode silently attaches related listings on every save. Pre-Fill mode populates the form fields with suggestions for the user to review before saving.
Author Restriction AwarenessRespects the Related Listing field’s author restriction setting — when set to a specific author, only that author’s listings are fetched.
Status Restriction AwarenessRespects the field’s status restriction, filtering by allowed post statuses.
Relation Type AwarenessHandles “has many”, “has one”, and “belongs to” relationship types with correct directionality.
Configurable Fetch LimitSet a maximum number of related listings to fetch (default: 100) to prevent server overload.
Admin ExclusionOptionally disable the plugin for admin users, so only listing owners benefit from auto-fill.
Custom Field Key SupportWorks with Related Listing fields using any custom key, not just the default field.

How It Works

The plugin reads the configuration you’ve already set up on your Related Listing fields in the MyListing listing type editor — specifically the listing type filter, author restriction, and status restriction. It then uses those same filters to automatically find and attach matching listings.

There are two operating modes:

Auto-Fill Mode (Default)

This is the default mode and requires no configuration.

1. A listing is saved (created or updated).

2. The plugin reads the listing’s type and finds all Related Listing fields on that type.

3. For each Related Listing field, it queries for matching listings based on the field’s configured filters (listing type, author, status).

4. It removes any old relationships and inserts the new ones into the database with the correct parent/child direction.

5. The listing now has auto-populated related listings visible on the frontend single listing page.

Note: In auto-fill mode, related listings are attached silently on every save. The user does not see or approve the selections — they are applied automatically based on the field’s configuration.

Pre-Fill Mode (Optional)

When enabled in settings, this mode gives users the opportunity to review and modify the suggestions before saving.

1. The user opens the Add Listing or Edit Listing form.

2. The plugin identifies all Related Listing fields and checks if they’re empty.

3. For empty fields, it shows a “Loading related listings…” overlay and fetches matching listings.

4. The field is populated with suggestions. The user can review, add, remove, or modify them before submitting.

5. Fields that already have selections are left untouched — pre-fill only targets empty fields.


Auto-Fill vs. Pre-Fill: Which to Use?

Auto-Fill (Default)Pre-Fill
When it runsEvery time a listing is savedWhen the Add/Edit Listing form loads
User involvementNone — fully automaticUser reviews and can modify suggestions
Overwrites existing selectionsYes — replaces on every saveNo — only fills empty fields
Best forSites where related listings should always be complete and consistentSites where listing owners should have control over their related listings

Settings

Navigate to “Auto Related Listings” in the WordPress admin sidebar to access the settings page.

SettingDefaultDescription
Pre-fill the related listings field only?OffWhen OFF (default): Auto-fill mode — related listings are automatically attached to the database every time a listing is saved. The user has no opportunity to review or modify the selections. When ON: Pre-fill mode — Related Listing fields are populated with suggestions on the frontend form, but nothing is saved automatically. The user can review and modify before submitting. Pre-fill only works on empty fields.
Max number of pre-fill to fetch?100Limits the number of related listings queried. Applies to both auto-fill and pre-fill modes. Set to -1 for unlimited. Lower this value if you experience timeouts on large sites.
Turn off for admin users?OffWhen ON: The plugin is disabled entirely for Administrator users. Only non-admin users (listing owners) will have related listings auto-filled or pre-filled. Useful when admins want to manually control related listing assignments.

Note: For pre-fill mode, the Related Listing field must be visible on the form. Hidden fields cannot be targeted by the pre-fill script.


How Relationship Types Are Handled

MyListing’s Related Listing field supports three relationship types. The plugin handles each one differently:

Relation TypeDirectionPlugin Behavior
Has ManyParent → Multiple ChildrenThe saved listing is the parent. All matching listings become children. Old relationships are removed and replaced with the new set.
Has OneParent → Single ChildSame as “Has Many” — the saved listing is the parent. Matching listings are attached.
Belongs ToChild → Single ParentThe saved listing is the child. Only processed if exactly one parent listing is found. If multiple potential parents exist, the field is skipped to avoid ambiguity.

What the Plugin Reads from Your Field Configuration

The plugin doesn’t have its own filter configuration — it reads everything from the Related Listing field’s settings in the MyListing listing type editor. This means whatever filters you’ve set up there are automatically used:

Field SettingHow the Plugin Uses It
Listing Type filterOnly listings of the specified type(s) are queried. If no listing type is configured on the field, no query is executed and nothing is attached.
Author RestrictionWhen set to a specific author, only that author’s listings are fetched. When set to “any”, all authors’ listings are included.
Status RestrictionFilters by allowed post statuses (publish, pending, etc.).
Relation TypeDetermines the parent/child direction of the relationship (see above).

Important: The Related Listing field must have a listing type filter configured in the listing type editor. If the listing type filter is empty (no types selected), the plugin will not query any listings and nothing will be attached.


Frequently Asked Questions

Does the plugin require any configuration?

No. In its default auto-fill mode, the plugin works immediately out of the box with zero configuration. It reads the Related Listing field’s filters directly from the MyListing listing type definition. The settings page is only needed if you want to switch to pre-fill mode, limit the fetch count, or exclude admin users.

Will it overwrite my manually selected related listings?

In auto-fill mode, yes — every save replaces the existing related listings for “has many” and “has one” fields with the auto-discovered ones. In pre-fill mode, no — it only fills empty fields and leaves existing selections untouched.

Does it work with custom Related Listing field keys?

Yes. The plugin reads all Related Listing type fields from the listing type’s configuration, regardless of their custom key name.

Does it support “belongs to” relationships?

Yes, but with a constraint. For “belongs to” relationships, the plugin only processes the attachment if exactly one parent listing is found. If multiple potential parents exist, it skips the field to avoid ambiguity.

Can I use it alongside MyListing’s native Related Listing selection?

Yes. In pre-fill mode, the plugin merely suggests listings — the user can still manually add or remove selections. In auto-fill mode, the plugin’s selections will override manual ones on each save.

What if no listing type is configured on the Related Listing field?

The plugin will not query any listings and nothing will be attached. A listing type filter must be configured on the field in the MyListing listing type editor.

Does the plugin affect site performance?

In auto-fill mode, it adds processing time to each listing save (one query per related-listing field plus database writes). In pre-fill mode, it adds a single request when the Add/Edit Listing form loads. The “Max number of pre-fill to fetch?” setting helps control the query load.

What is the maximum number of related listings it can attach?

Controlled by the “Max number of pre-fill to fetch?” setting (default: 100). Set to -1 for unlimited, but be cautious on large sites as this may cause server timeouts or memory issues.


Troubleshooting

Related Listings Not Being Attached (Auto-Fill Mode)

CauseSolution
No listing type configured on the fieldThe Related Listing field must have a listing type filter configured in the MyListing listing type editor. If it’s empty, no listings are queried.
Author restriction too narrowIf the field’s author restriction is not set to “any”, only listings owned by the current listing’s author will be found. If the author has no other listings of the required type, no relationships are created.
Admin exclusion enabledIf “Turn off for admin users?” is enabled and you’re logged in as an Administrator, the plugin won’t run. Test with a non-admin account.
MyListing not activeCheck for the red admin error notice. The plugin does nothing if MyListing is not detected.
Conflicting pluginsOther plugins hooking into listing save events at higher priority might interfere. Try deactivating other plugins to test.

Pre-Fill Not Working

CauseSolution
Pre-fill mode not enabledCheck the “Pre-fill the related listings field only?” checkbox on the settings page.
Related Listing field not visibleThe pre-fill script targets visible form fields. If the field is hidden or not rendered on the form, pre-fill cannot target it.
Field already has valuesPre-fill intentionally skips fields that already have selections. Clear the field to see pre-fill in action.
JavaScript errorOpen the browser console (F12 → Console) to check for errors or failed requests.
Max limit too highIf your server times out during the request, lower the “Max number of pre-fill to fetch?” setting.

“Loading Related Listings…” Stays Visible

CauseSolution
Request failedCheck the browser console for network errors.
Server timeoutLower the max pre-fill limit in the settings.
jQuery not loadedEnsure jQuery is loading on the page. Some optimization plugins may defer or remove jQuery.

“MyListing Theme Not Detected” Error

The MyListing theme must be installed and active. Go to Appearance → Themes to verify. If using a child theme, ensure the parent MyListing theme is properly configured.

Settings Page Not Appearing

CauseSolution
MyListing not activeInstall and activate the MyListing theme first.
Insufficient permissionsOnly users with the manage_options capability (typically Administrators) can access the settings page.
Plugin not activatedVerify the plugin is active in Plugins → Installed Plugins.

For further support, visit codicts.com or contact us at support@codicts.com.

CoDicts Co., Ltd. © 2021-2026. All rights reserved