EP_ATTACHMENT will insert rules for things attached to posts (and custom post types), but not unattached media.
You can make this work by adding it to EP_PAGES instead-
add_rewrite_endpoint( 'foo', EP_PAGES );
Related Posts:
- How can I modify the permalink via a filter?
- Newbie question: no index.php? in my plain wordpress permalink
- Continue execution after WP REST API response
- Change links automatically to affiliate links
- Rewrite sub folder dynamically with country code in WordPress using PHP
- Use WordPress’ URL rewrite engine
- Rename “Portfolio” slug?
- How to rewrite URL with PHP variables with htaccess to a normal looking URL?
- WordPress custom slug (endpoint) and compare all links
- Static variable and add_rewrite_rule?
- Nesting if statements to echo only one string based on what tag was filtered?
- How to change home or site url using action hooks or filter?
- Why do WordPress rewriites seem to work differently for posts vs pages?
- Performance impact of rewriting WordPress URLs
- Is sanitize_title_with_dashes formatting function too liberal (in terms of accepted characters)?
- Using WP-API and SSE not authenticating user ID
- Changes in permalink structure in WordPress and how to apply to in-site links
- WordPress Persistent connection rule does not work for “posts”
- Append query string to all URL’s
- custom rewrite rule help! Custom rewrite rules not applying to custom post type
- subdirectory index.php is not working
- Use URL Rewrite as well as $_GET parameters in URL?
- How to modify URL (add GET values) after front end form submission?
- parts of url disappear when using # inside href=”” [closed]
- My php header() function is not working [closed]
- Create custom permalinks to show Custom Post Type’s relationship?
- Add .htm extention to a custom taxonomy
- Help with .htaccess and Login with Subfolders
- WordPress add_rewrite_rules for custom URLs ending in .html
- Rewrite with pagination /foo/page/2/ to posts of a given category, page 2
- Divi change project category slug
- Is this a correct usage of ob_start() in my WordPress project?
- Custom route and query
- How do i add slugs to a URL, but still redirecting to the same page
- Nginx WordPress and another Web app URL structure
- Custom post type url Rewrite (conflicting with page url)
- WordPress Rewrite Rule
- Why is home page content not displaying with this rewrite rule?
- Modifying WP URL handing code?
- How to deal with a GET variable of ‘name’?
- How to define a rule in functions.php that ONLY disables the default wp functionality that undesirably changes ‘&’ to ‘#038;’?
- How to pass username in affiliate link in wordpress website
- WP_REST_Response – How to return Gzip answer and add Content-encoding header?
- Test the existence of a page/article by its URL, taking in consideration the URL rewriting by filters
- url not using query string no longer working
- php code for outputting a custom page in my account
- Current WordPress Page Title as Search Parameter into A Tag
- How does one make a URL return dynamic JSON with custom Content Type?
- Need to forward Data from WooCommerce Webhook sent to same site WordPress REST API custom endpoint
- URL rewrite rule
- How does WordPress rewrite URLS using its PHP scripts
- How can I turn a url with get method as a clean url with segment as the get method?
- WordPress Rewrite Issue
- How to print redirected query string variables to the page?
- Multiple URL from Custom post name
- Why isn’t my custom function kicking in from my functions.php file?
- Difference in Get Variable Location
- WordPress adding in site URL to header links
- Dynamically append custom post type to end of url
- WordPress add parameters with friendly url structure
- Custom taxonomy with page post type – WordPress
- What is different about using admin-ajax.php in an endpoint and just submitting a form from the front end?
- REST API Plugin Update call back not updating the plugin
- Remove slug of multiple custom post types with and without hierarchical
- error_log() output for print_r() appearing on page
- Nginx FastCGI_Cache Vs PHP Caching
- How to display multiple Post meta_key/meta_values by SQL query
- How To Customize Position of »add to cart« of WooCommerce on Product Page [closed]
- Shortcode created to check language not works
- Sort posts from multiple sites by date
- Change Width of Featured Image Thumbnail on Add/Edit Post Page
- Listing all sub-pages?
- Create table in database when activating plugin
- Implement a multi-value input field where the number of entries is not limited
- How can I export post data in xml format?
- How to create an endpoint without creating sub endpoints?
- Getting my head round WordPress filter
- allow user to select pages from dropdown in my plugin
- How to set a custom path, for ajax image upload folder in admin?
- Recent post display using shortcode
- Can I use `.phtml` instead of `.php`
- conditional statement for custom taxonomy
- WP_cron won’t trigger my action
- how to save selection meta data in user profile on frontend
- How to get a list of all possible values of a specific user meta key?
- Use object in template part
- Can’t extend some core classes
- Output Buffering – Everything between wp_head and wp_print_footer_scripts?
- functions.php is being included twice, creating PHP fatal errors
- Hide Hamburger Menu On Specific Page (Front Page/Home Page)
- Accessing the database from a plugin outside of action hooks
- Menu Limitations
- Iterate through posts based on array of categories
- selected option if current category is the value
- Custom query, checking values of multiple meta keys
- Genesis framework comments broken?
- running an existing WordPress site from Visual Studio Code?
- get_post_meta returns on side but it doesn’t return on bottom of admin page
- hide “Open in New Tab” checkbox in link field
- Side bar only if it’s not a single post or a specific page