Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using a function to display all files attached to a post and listing them as links. The result is something like this:

echo '<a href="' . wp_get_attachment_url($attachmentImage->ID) . 
          '" class="dir-attachment" />' . wp_get_attachment_url($attachmentImage->ID) . '</a>';

As expected, this display a hyperlinked version of the hyperlink, but I'd like to clean it up. Is there some way to strip the http://mydomain/wp-content/uploads from the second instance display the file name only, rather than the full path?

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

Try this:

basename(get_post_meta( $attachmentImage->ID, '_wp_attached_file', true));
share|improve this answer
    
Perfect. Thanks! –  John Chandler Jan 14 '11 at 19:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.