Support » Plugin: WPAdverts - Classifieds Plugin » Add Hyperlink to whatsapp and website

  • Hello,

    Please how can I make the whatsapp and email appear as a clickable link

    add_action( "adverts_tpl_single_bottom", function() {
        remove_action( "adverts_tpl_single_bottom", "adverts_single_contact_information_box", 2000 );
        add_action( "adverts_tpl_single_bottom", "my_adverts_single_contact_information_box", 2000 );
    }, 100 );
    function my_adverts_single_contact_information_box( $post_id ) {
    
        ?>
        <div class="adverts-contact-box adverts-contact-box-toggle">
            <p class="adverts-contact-method">
                <span class="adverts-icon-phone adverts-contact-icon" title="<?php _e("Phone", "adverts") ?>"></span>
                <span class="adverts-contact-phone"></span>
            </p>
    		
    		<p class="adverts-contact-method">
               <span class="adverts-icon-whatsapp adverts-contact-icon" title="<?php _e("WhatsApp", "adverts") ?>"></span>
               <span class="adverts-contact-whatapp"><?php echo esc_html( get_post_meta( $post_id, "whatsapp_field", true ) ) ?></span>
            </p>
    
            <p class="adverts-contact-method">
               <span class="adverts-icon-mail-alt adverts-contact-icon" title="<?php _e("Email", "adverts") ?>"></span>
               <span class="adverts-contact-email"></span>
            </p>
    		
    		<p class="adverts-contact-method">
               <span class="adverts-icon-internet-explorer adverts-contact-icon" title="<?php _e("Website", "adverts") ?>"></span>
               <span class="adverts-contact-website"><?php echo esc_html( get_post_meta( $post_id, "website_field_17", true ) ) ?></span>
            </p>
        </div>
        <?php
    }

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    to make the whatapp link clickable replace

    
    <span class="adverts-contact-whatapp"><?php echo esc_html( get_post_meta( $post_id, "whatsapp_field", true ) ) ?></span>
    

    with

    
    <span class="adverts-contact-whatapp">
    <?php $whatsapp = get_post_meta( $post_id, "whatsapp_field", true ) ?>
    <a href="<?php echo $whatsapp ?>"><?php echo $whatsapp ?></a>
    </span>
    

    similarly with email address replace

    
    <span class="adverts-contact-email"></span>
    

    with

    
    <span class="adverts-contact-email2">
    <?php $email = get_post_meta( $post_id, "adverts_email", true ) ?>
    <a href="mailto:<?php echo esc_attr( $email ) ?>"><?php echo esc_html( $email ) ?></a>
    </span>
    

    Im so sorry for the inconvenience I wanted to refer to the website url instead of email the email is already linked by default

    <span class="adverts-contact-website"><?php echo esc_html( get_post_meta( $post_id, "website_field_17", true ) ) ?></span>

    thanks

    Plugin Author Greg Winiarski

    (@gwin)

    To replace the website name with clickable link replace the line

    
    <span class="adverts-contact-website"><?php echo esc_html( get_post_meta( $post_id, "website_field_17", true ) ) ?></span>
    

    with

    
    <span class="adverts-contact-website">
    <?php $website = get_post_meta( $post_id, "website_field_17", true ) ?>
    <a href="<?php echo esc_attr( $website ) ?>"><?php echo esc_html( $website ) ?></a>
    </span>
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.