The attachment URL is created in wp-includes/link-template.php
in function get_attachment_link()
. And there is a filter for you, passing the WordPress URL and the post id for the attachment. You can hook into that filter and return the URL you need:
add_filter( 'attachment_link', 'wpse_56619_unprettify_attachment_url', 10, 2 );
function wpse_56619_unprettify_attachment_url( $link, $id )
{
return home_url( "/?attachment_id=$id" );
}
Related Posts:
- Change Attachment Post URLs to File URLs
- Change default URL of image attachment
- How do I change attachment slug from name to id
- Need help with simple rewrite rule (shouldn’t this be easy?)
- Attachment page gives 404 if user not logged
- custom url – add attachment’s id or name after post
- How to create a front end user profile with a friendly permalink
- Masking wp-content/themes/name/images to just images directory using htaccess
- Using custom/dynamic “slug” for a page
- How to make pages slug have priority over any other taxonomies like custom-post, post or category
- Use subdomain for certain urls
- Rewrite URL – how to do a SEO-friendly Unicode custom URL?
- Display posts with author in the url with custom post types
- Clash of the rewrites
- Query Vars for the Homepage?
- Disable wordpress pagination URL rewrite for specific page
- How to use Post Custom Metadata in Post Titles and Post Permalinks
- Using WordPress with Apache behind an nginx reverse proxy
- How do i change the search permanent links
- add_rewrite_rule() not playing nice with child pages
- rewrite_rule() not preserving the query string
- Custom rewrite rules are sending everything to index.php
- WordPress Network on IIS7/SQL Server – Rewrite Issues
- Custom comments
- How to Change Author Posts URL
- Change permalink for default archive – yearly
- Migrating a page to be an article
- Multiple Permalinks for Same Post
- How to perform a query at the URL?
- Is there a way to create alias without using htacess, permalinks or delving into code?
- Remove “/page/1” from the URL
- hard flush_rewrite_rules() not regenerating .htaccess
- Remove Query String from URL on Redirect – Redirection Plugin
- Nginx rewrite rules
- Cleanup URL for a custom page in wordpress
- Use custom template on certain URLs
- Rewrite Rules Are Redirecting and Not Passing VARs
- WordPress rewrite rules don’t need ^?
- How to rewrite taxonomy and tags URL
- Custom rewrite not working
- Changing WordPress Address URL disaster
- Prevent WordPress from Rewriting URL for one template
- Disable Pagination on Pages
- Rewriting a page with a custom parameter
- WordPress 3.9 breaks invalid permalinks.. code fix possible?
- Hide admin login without plugin
- How to add a custom redirect rule for Post as subdomains?
- How to preserve the query string while using add_rewrite_rule and default public query vars
- How do I display only the parent page in the url
- “View post” leads to odd URL
- Redirect HTTP to HTTPS for all sub domains (blog posts)
- Get url param no longer works when using add_rewrite_rule
- How to use add_rewrite_rule in subdomain
- Why is WordPress rewriting absolute URLs on staging site to include staging prefix when we manually point them at the live site?
- Rewrite the default post object’s permalink
- Map secondary domain to other’s virtual subfolder
- adding custom controller called by front-end
- rewrite attachment url with attachment title
- WordPress search rewriting
- Enpoint Not Found in Rewrite Tag Permalink
- Custom Rewrite Rules
- show ALL latest posts with archive.php on example.com/latest
- Adding a query string to only one page url
- Url rewrite with htaccess
- force www rewrite if wordpress put in a folder
- Current post ID – relative url
- How to use wp rewrite to hide form action url?
- Custom Structure permalinks error 404
- WordPress Rewrite rule is not working
- change the url in wordpress
- Redirect URL to an existing page with query string or #! added on
- remove archive from url :: marketpress
- Use URI suffix as parameter and ignore when resolving page
- add_rewrite_rule with optional parameters
- How to change url of specific posts with name of a root page
- Why wordpress rewrite my custom URL?
- Rewrite rule regex help required
- Redirect empty search to another page
- Rewrite dynamic URLs as pretty URLs in WordPress functions.php (add_rewrite_rule) – what’s wrong with my code?
- WordPress URL redirect and replace ? question mark
- WordPress index in subdirectory, blogposts in root directory
- Fresh install redirects to www, breaking page loads
- url restructure or rewrite having $_GET variables
- How to use a RewriteRule to change endpoint url
- Custom taxonomy Rewrite Rule
- I want to add one extra field to my URLs, I’m using Rewrite functions but it doesn’t work
- .htaccess RewriteRule to include post type and taxonomy
- What’s the best approach to do this?
- Font Page overrides rewrites
- WordPress Rewrite: Ignore Specific Pattern
- rewrite rule for home/index page
- WordPress index page is returning 404 and admin page requires /index.php in url
- Stop wordpress to redirecting home page if no page found
- Additional .htaccess rules based on wp page
- URL Rewriting in WordPress
- How to change search url produced by ‘s GET method?
- Hide / rewrite download link
- Lost WordPress website access after changing URL [closed]
- Spurious URL structure (Adding extra /0/s)
- WordPress is adding pagination for all pages like www.example.com/page/123. How to remove that?