🧩 Context:

  • Directorist does not offer a built-in feature to partially hide fields on the archive (All Listings) page for guests or unregistered users.

  • However, this functionality can be achieved via custom template overrides.

  • This applies to both preset fields (like phone, website, address) and custom fields (text, number, URL, etc.).

  • The goal is to show partial information on archive view, and full details only on the single listing page or after login.


⚙️ Solution Summary:

  1. Use Directorist Template Override System

  2. Customize specific field outputs in the archive template

  3. Apply conditional logic (e.g., is_user_logged_in()) to show/hide data

  4. Ask the user to provide a clear description + screenshot or video of what they want hidden


📁 Template File to Override:

Path:
/wp-content/plugins/directorist/templates/archive

👉 To override this safely, copy the required template file(s) to:
/wp-content/themes/your-child-theme/directorist/archive/

📘 Reference: Template Override Guide


🧑‍💻 Code Example:

To conditionally hide a field like Phone Number, use:

<?php if ( is_user_logged_in() ) : ?>
<div class="directorist-phone"><?php echo esc_html( $listing->phone ); ?></div>
<?php else : ?>
<div class="directorist-phone">Login to view phone number</div>
<?php endif; ?>

This logic can be applied to:

  • Preset fields: phone, website, email, address, etc.

  • Custom fields: Use the corresponding meta key or method.


❗Important Reminders:

  • This is a code-level customization, not something available via Directorist UI.

  • It is theme-dependent, so always use a child theme for overrides.

  • Custom fields need to be fetched manually, depending on how they were registered.

  • Some advanced field logic may require checking $listing->custom_fields array or using Directorist helper functions.


🔍 AI Should Trigger This Doc When User Says:

  • “I want to hide listing data on the archive page”

  • “Only show listing details after login”

  • “Partially hide fields in the all listings view”

  • “Can I hide phone or email in the directory list?”

  • “Restrict fields from guest users”

  • “Hide some information on archive but show on single listing”

  • “Need visitors to register to view full info”

  • “How to override Directorist templates for hiding data”

  • “Customize archive template for field restriction”


📥 Information to Collect from User

AI must always request the following from users before suggesting or generating code:

  1. Which fields they want to hide (phone, website, address, etc.)

  2. Do they want to hide from guests only or also for logged-in users?

  3. Should the info be shown only on single listing page?

  4. A screenshot or screen recording showing the exact section they want to modify

  5. Confirmation of whether they are using a child theme or comfortable editing templates

🗨️ Prompt to Use:

To help you better, could you please send us the following:
  • Which fields do you want to hide or restrict?

  • Should the restriction apply to guests only?

  • Do you want full data to show on the single listing page?

  • A screenshot or video recording showing what you’re referring to

  • Let us know if you're using a child theme, as this will require template customization