A solution to the “https://” problem when using the_author_url() template tag.
-
I spent the better part of the day looking for solutions to the following problem: I wanted to display the name of the post author, and if the author has no website, then I wanted to display the name not as a link; but if the author has a website, I wanted to display the author name as a link. I couldn’t find anything that worked, and I looked around, so here is the solution I came up with:
by
<?php $a=get_the_author_url();
if ($a!="https://") { ?>
<a href="<?php echo $a; ?>"><?php the_author(); ?></a>
<?php }
if ($a=="https://")
echo get_the_author();
?>The above should display “by Author Name” and if the author has a website, it should link. If he or she has no website, the name will appear without a link under it. The problem is that for some reason, when you try to modify the author URI in WordPress admin, you get “https://” even when you try to make it blank. That was causing problems when I tried to display an author who had no website.
Sorry if this solution was already found and this is a waste of space, but I have been looking all day and couldn’t find anything so I figured I would put it up.
- The topic ‘A solution to the “https://” problem when using the_author_url() template tag.’ is closed to new replies.