1. Enabling the key field:
Please copy and paste the following code at the end of the "functions.php" file of the currently activated theme folder.
- add_filter('directorist_custom_field_meta_key_field_args', function ($args) {
- $args['type'] = 'text';
- return $args;
- });
2. Create a custom Textarea field:
Please create a custom Textarea field and make sure the key ( meta key ) is "custom-whatsapp".
3. Template Override:
Please read the template override documentation before you start this process. This will help you to understand how to override the templates properly.
Template Override Documentation
a) Override the single listing template:
Please create a file "directorist/single/custom-fields/text.php" in your currently activated theme folder with the following code -
- <?php
- /**
- * @author wpWax
- * @since 6.7
- * @version 7.0.5.2
- */
- if ( ! defined( 'ABSPATH' ) ) exit;
- ?>
- <div class="directorist-single-info directorist-single-info-text">
- <div class="directorist-single-info__label">
- <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon );?></span>
- <span class="directorist-single-info__label--text"><?php echo esc_html( $data['label'] ); ?></span>
- </div>
- <?php if (isset($data['field_key']) && $data['field_key'] == "custom-whatsapp") : ?>
- <div class="directorist-single-info__value">
- <a target="_blank" href="https://wa.me/<?php echo str_replace(' ', '', $value); ?>"><?php echo esc_html( $value ); ?></a>
- </div>
- <?php else: ?>
- <div class="directorist-single-info__value"><?php echo esc_html( $value ); ?></div>
- <?php endif; ?>
- </div>
4. Output:
No comments:
Post a Comment