The table cell in the below code is being used as part of a messaging system and it returns the url as a link to the attached file to the message.
echo '<td width="25%"><a href="'.wp_get_attachment_url($row->file_attached).'">'.wp_get_attachment_url($row->file_attached).'</a></td>';
This is fine and works well, my problem is that I would like it to either only show the title of the file ( not the full url) or even better would be to have it print "file attached" as a link, but if there is no file to get could it say "no file attached"
I am a complete novice at this and I am trying to stuble my way through. It would be great if somebody could push me in the right direction.
Thanks
If you just mean you want the text of the link to be different, this is really basic HTML (not PHP):
<a href="/some/url">some text for the link</a>
In your case, you have the URL repeated as the contents of the <a>
tag, but you can put whatever you want there.
Edit: To only show the link if there is a link to show, you need an if
statement, probably the simplest piece of programming logic there is:
if ( $row->file_attached ) {
// echo a link
}
else {
// echo something other than a link
}