• Resolved mgnelsonhill

    (@mgnelsonhill)


    Hi again-

    I’m trying to add custom contact info or html to my author box instead of a button as you describe the process here:

    I followed the first step of adding the following to the functions.php:

    
    function my_epl_custom_user_contact( $contactmethods ) {
    
    	$contactmethods['direct-line']	= __( 'Direct', 'easy-property-listings' );
    
    	$contactmethods['main-line']	= __( 'Main', 'easy-property-listings' );
    
    	return $contactmethods;
    
    }
    
    add_filter ('user_contactmethods','my_epl_custom_user_contact',10,1);

    Then in the widget-content-author-tall.php I added the following:

    <?php if ( $contactmethods->get_author_direct_line() != '' ) { ?>
    					<span class="label-mobile"><?php _e('Direct', 'easy-property-listings' ); ?> </span>
    					<span class="mobile"><?php echo $contactmethods->get_author_direct_line() ?></span>
    				<?php } ?>

    after

    <?php if ( $epl_author->get_author_mobile() != '' ) { ?>
    					<span class="label-mobile"><?php _e('Mobile', 'easy-property-listings' ); ?> </span>
    					<span class="mobile"><?php echo $epl_author->get_author_mobile() ?></span>
    				<?php } ?>

    I then check the page and everything below the code I inputted into the template is gone and so are my footers.

    Thanks again for your time!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Merv Barrett

    (@mervb1)

    Hi there,

    You would have encountered a fatal error as you created a function that does not exists

    get_author_direct_line

    Instead use the built in WordPress function to retrieve your extra data

    $direct_line = get_the_author_meta( 'direct-line');

    then you can use

    <?php if ( $direct_line != '' ) { ?>
    	<span class="label-mobile"><?php _e('Direct', 'easy-property-listings' ); ?> </span>
    	<span class="mobile"><?php echo $direct_line; ?></span>
    <?php } ?>

    Consider contacting us via Support for additional assistance.

    Plugin Author Merv Barrett

    (@mervb1)

    Here is a similar example on adding a custom icon to the author box.

    How to add a custom link and icon to the author box

    Thread Starter mgnelsonhill

    (@mgnelsonhill)

    That’s great Merv- thank you so much!
    One problem I encountered, however, was with the secondary author- it seems that both author profiles display the same information from the custom fields- as in whatever content I put into the new fields under my profile now appears in everyone’s profile. Is there something else I would need to setup for the secondary author?

    Thanks again!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom fields to author box’ is closed to new replies.