If understand your question correctly, I think this can get the job done. Use get_attachment_link
instead of wp_get_attachment_url
and then echo the title.
<?php
$attachment_id = 2582;
$attachment_page = get_attachment_link( $attachment_id );
?>
<a href="https://wordpress.stackexchange.com/questions/255020/<?php echo $attachment_page; ?>"><?php echo get_the_title($attachment_id ); ?></a>
Related Posts:
- Update media file url in wordpress media library
- How to make media URLs Unique
- How to Fix HTTP Error When Uploading Images?
- Unwanted media library URLs in posts?
- How can I bulk delete media and attachments using WP-CLI?
- Get all posts (of any post type) an attachment is used in
- Password protect some uploaded files, so only logged-in users can view them
- Unattaching unlinked images
- Pages redirected to attachment post
- How to retrieve alt attribute for an attachment (uploaded image)?
- How to fetch only media that was already attached to a post/page?
- Audio file’s length (duration) is missing from Attachment Details in Media Library [closed]
- Post edit – Media Library – Only get images from current post
- Attach media to multiple posts
- Set a custom URL for image in the Media Library?
- How do I modify the “Insert Media” lightbox in the admin to only show media items from a category?
- How can I change a media attachment URL/slug, so that I can use that slug for a page?
- Find file url in post content and add it to media library
- What template is used for viewing Media Library Files?
- Get images attached to a specific page
- WordPress Attachments with old images
- Uploaded images result in a file url with full path on disk appended
- get all images from the wordpress media library with link to the post they are associated with
- How to get a page url segment on wordpress?
- How can i set media attachments to the author of the post or page for already existed posts with attachments
- Media Library Mess After FTP … /uploads
- Adding attachment custom field metadata to TinyMCE tag
- How to get the correct URL on my wordpress site?
- controlling whether upload is attached to post or not
- Media library only show 2 items per page?
- Replace media external links with local links
- How to Protect Uploads, if User is not Logged In?
- Add a menu item to WordPress 3.5 Media Manager
- How do you retrieve a post by slug name through REST API?
- Enhance Media Manager for Gallery
- Why “?v=hash” is added to my URLs? [closed]
- How to manage attachment relationships for specific posts in WP 3.5+
- Programmatically adding images to media library
- Detecting a WordPress URL without doing a full HTTP GET?
- How does WordPress generate URL slugs?
- Use a template file for a specific url without creating a page
- How does routing on wordpress work?
- Extend Media Library
- Redirecting to old domain after migration
- Programmatically get images by URL and save in uploads folder
- Custom plugin route in WordPress
- WordPress 3.5: Setting custom “full URL path to files” in the Media Library?
- Why is ?doing_wp_cron being appended to my URLs
- Delete an attachment in the WP media modal window
- Upload images to remote server
- How to trigger a refresh in the media modal
- How to use taxonomies on attachments with the new Media Library?
- Custom collection in media manager?
- How to show all available images in WP’s media library when using the Polylang plugin?
- How to remove file versions from the file source links in wp_head?
- Delete Associated Media Upon Page Deletion
- use query string in URL to display content on the page
- Change default URL path (/blog/) of blog posts
- Difference between esc_url() and esc_url_raw()
- Media library to list images only user uploaded
- WordPress 3.5 Media Manager – add a button
- How to Change 404 page title
- Programmatically adding images to the media library with wp_generate_attachment_metadata randomly fails
- How to deal with WordPress on localhost
- Problem with guids and absolute links
- Rendering the uploaded file in a wp.media object
- Uploaded images don’t show in Media Library if there are special characters in IPTC Keywords
- Remove “Insert from URL” link in Media upload – WP 3.5
- Which filters or actions to use after a media upload and delete?
- How do I force WordPress to show most recent version of images in the media library?
- WordPress Media Manager 3.5 – default link to
- Proper way to add a button to the top menu of the media library?
- Stop WordPress from reserving slugs for media items?
- Changing attachment urls?
- Protecting direct access to PDF and ZIP unless user logged in (without plugin)
- Can I use the wp media uploader for my own plugin?
- How to wp_upload_bits() to a sub-folder?
- Open media frame and select an attachment
- Filter by post category in Media Library
- Change Media Uploader default directory
- How to convert the file path to a URL of the same file?
- Add menu and submenu in admin with a URL instead of slug?
- display image size in media library screen
- How to hide media uploads by other users in the Media menu?
- “Add Media” only shows “Full Size” under Attachment Display Settings
- Where do the favicons for Media Files come from
- Why is WordPress saving full-urls to the database?
- media_handle_upload for local files?
- Expanding new Media Uploader in WordPress 3.5
- Put the media uploader in a metabox
- How to capture the selection:toggle event fired by wp.media
- Uploading Multiple Attachments From Front-End With A Description
- get_attached_media() returns empty array if media file already used by another post
- complex restriction of items in media library
- Edit image / Delete image link
- Get taxonomy slug from url
- Is there a user-facing interface to edit an attachment’s permalink?
- How do I detach images from posts?
- Is it possible to trigger some JavaScript when Media Popup is opened?
- How to call WP3.5 Media Library manager?