kahfooi
Member
Posted 13 years ago #
Below is the code i used in my sidebar to display the user website.
<div><a href="<?php the_author_meta('user_url'); ?>>View website</a></div>
My problem is, it still showing "View website" when the user didn't fill in any web url in their profile.
How can i make it disappear when the user don't have any website in their profile? Thanks!
<?php if(strlen(the_author_meta('user_url'))) { ?>
<div><a href="<?php the_author_meta('user_url'); ?>>View website</a></div>
<?php
}
?>
kahfooi
Member
Posted 13 years ago #
do i need a echo before the <div>?
kahfooi
Member
Posted 13 years ago #
tried the code, seems like the { } not working. Only output the user_url.
Try:
<?php
if(strlen(get_the_author_meta('user_url'))) {
echo '<div><a href="' . get_the_author_meta('user_url') . '">View website</a></div>';
}
?>
Oh yah - what tmoorewp said. I don't use the template tags much and I forget that uh, yah, they're meant for outputting.
kahfooi
Member
Posted 13 years ago #
Much thanks to DeannaS and tmoorewp. It's working now :D