I have added some code to my website to show the user's website link (please see below) but the website link is not clickable so
https://mywebsite.com
or https://www.mywebiste.com
in that field it only show the website name like this mywebsite.com
Could you help me to achieve it?
add_action( 'bp_profile_header_meta', 'display_user_color_pref' );
function display_user_color_pref() {
$args = array(
'field' => 'web', // Field name or ID.
);
$my_bio_excerpt = wp_trim_words( bp_get_profile_field_data( $args ), 40, '' );
if ( $my_bio_excerpt ) {
echo '<div class="my_bio">';
echo '' . $my_bio_excerpt; // Put some text if needed between the '' paragraphs.
echo '</div>';
}
}
Thank you.
I tried to add this echo line to make the website link clickable but is not working, are there some paragraphs missing?
echo <a href="<?php echo $my_bio_excerpt; ?>" class="">click here</a>
I would suggest to add an <a href></a>
to make it a link - see https://www.w3schools.com/tags/att_a_href.asp
Your PHP syntax is wrong in:
echo <a href="<?php echo $my_bio_excerpt; ?>" class="">click here</a>
Should be:
echo "<a href=\"$my_bio_excerpt\" class=\"\">click here</a>";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.