• Resolved freizeitmonster

    (@freizeitmonster)


    Hi,

    i would like to use a custom input field for instagram names of my customers.
    In the add ad form the users can insert their instagram names (e.g. @testuser). In the detail page users should be able to click on the username and will redirect to the instagram profile of the author.

    How can i realize this?

    Thank you in advance.

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

    (@gwin)

    Hi,
    you would need to mark this field in the Custom Fields editor as visible in forms only, then in your theme functions.php file (or in a blank plugin with code snippets) add the code below

    
    add_filter( "adverts_tpl_single_details", function($post_id) {
        $insta = get_post_meta( $post_id, "instagram_profile", true );
        if( empty( $insta ) ) {
            return;
        }
        ?>
        <div class="adverts-grid-row">
            <div class="adverts-grid-col adverts-col-30">
                <span class="adverts-round-icon adverts-icon-instagram"></span>
                <span class="adverts-row-title"><?php _e("Instagram", "wpadverts") ?></span>
            </div>
            <div class="adverts-grid-col adverts-col-65">
                <?php $url = sprintf( "https://instagram.com/%s", $insta ) ?>
                <?php echo sprintf( '<a href="%s">%s</a>', $url, $insta ) ?>
            </div>
        </div>
        <?php
    } );
    
    Thread Starter freizeitmonster

    (@freizeitmonster)

    Works great.
    Thank you very much!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Clickable custom field in ad details page (e.g. instagram)’ is closed to new replies.