Jump to content

function echos from inside an if statement and how do i find if exists


ricky spires

Recommended Posts

hello

 

im having a problem with my if statement in wordpress

 

the if is inside a function and includes another function.

 

if i do this

the_author_meta('linkedin', $author->ID);

 

it echos out a linkedin address: uk.linkedin.com/pub/andrew-adie/b/858/985@adiemoi

 

 

if have put it into a <a> tag to tidy it up

echo '<h5><a href="';
the_author_meta('linkedin', $author->ID);
echo '">Linkedin</h5>';

 

so now i get a link called linkedin.

 

i want the link to only appear if the function "the_author_meta('linkedin', $author->ID);" is not empty

so i tried this not im not sure if this is the correct way ???

 

if(the_author_meta('linkedin', $author->ID)){
echo '<h5><a href="';
the_author_meta('linkedin', $author->ID);
echo '">Linkedin</h5>';
}

 

also when i run this code i get this echoed out:

 

uk.linkedin.com/pub/andrew-adie/b/858/985@adiemoi

 

so it looks like its echoing the function from inside the if and the if is not working anyway because not getting any "Linkedin" links showing.

 

so how can i get it to only show Linkedin links if the exist ?

 

thanks

 

rick

You need to make the_author_meta() return it's data not echo it. If it is a built in Wordpress function, then it (like a lot of things in wordpress) is floored and you will need to find an alternative / hack the current implementation / write a wrapper capturing it's output into a buffer.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.