Just faced the same situation and stumbled upon this question while googling.
It seems like this isn’t possible. Core itself just appends strings to the URL if pretty permalinks are enabled, see https://core.trac.wordpress.org/browser/tags/3.9.1/src/wp-includes/link-template.php#L571
For anyone interested in this: You can do something like this in your code:
if ( '' != get_option('permalink_structure') ) {
// using pretty permalinks, append to url
$read = user_trailingslashit( get_permalink() . 'test' ); // www.example.com/pagename/test
} else {
$read = add_query_arg( 'test', '', get_permalink() ); // www.example.com/pagename/?test
}
This solution is also was also recommended by Jon Cave in a comment on the official make blog: https://make.wordpress.org/plugins/2012/06/07/rewrite-endpoints-api/#comment-686
Related Posts:
- remove “index.php” from permalinks
- Creating custom permalink structure for languages
- Getting the Site URL Including the Front Base
- Update URL Snippet to Canonical Permalink URL
- “.#[random-char-string]” being inserted at end of URLs
- URL Rewrite + Page + Custom Post Type = Unusual Redirect
- Pretty Permalinks
- How to create a permalink structure for posts in a specific category
- Remove subfolders from URL
- flexible rewrite ‘ramble’ URLs with WordPress
- Custom rewrite rules for feeds of custom queries (query_var query strings in URL)?
- How to Modify Existing Rewrite Rules?
- custom permalink/shortlink with base62 encoded post ID
- How to reset canonical URLs / fix redirect loop
- Change blog segment of URL
- Force wordpress to display page with same url structure as categories
- How can i have a custom post type with more slugs for each post?
- URL rewriting: removing the site’s basename for a specific category
- mod-rewrite exception? keep #hash in matching urls?
- Remove parent page from url
- Getting back a permalink from custom url
- Bulk append URL (add word to slug)
- Access posts while mod_rewrite is broken
- Can I change the URL structure for a CPT only?
- Multiple Taxonomy Items for Separate URLs
- WordPress keeps removing query var from the URL
- How to construct a dynamic rewrite rule for child pages that passes more than one query var
- Using a template file for a specific custom URL
- Extra url paths as variable
- Passing parameter through permalink structure
- rebuilding/ rewriting a url to make it SEO friendly
- a way to support totally different url structure
- How to change URL of my pages?
- Custom Permalink Base
- Include language variable in url
- How to get the perfect WordPress, WooCommerce, Custom Post Type pretty permalinks?
- How does WordPress create URLs that Apache knows about?
- How does WordPress handle permalinks?
- Adding another word in front of post url
- How to add a custom URL placeholder to author archives?
- permastruct for custom post type not working in one of four cases
- How to Remove Slug From Database?
- Remove parent slug for child pages
- Nice RSS Feed URLs for each custom post type
- Change the custom post type permalink
- Auto 301 to full post permalink? (using /posts/%post_id%/%postname%)
- Rewrite url / permalink for default archive – yearly / monthly
- Permalinks, Rewrites, Get Variables, Oh My!
- Image Attachment Url Rewrite
- Rewrite Page with a slug before page name
- Can’t get rewrite rules working
- Can two products with the same name but different category produce unique URLs?
- When is it a good idea to build a permalink structure from scratch?
- If the only permalink setting is %postname% what happens in the case of old duplicates?
- Rewrite url without flushing the database?
- Get closest page ID from URL
- How to show the homepage on a different url, like site.com/blog instead of site.com?
- remove sub-category of Custom Post Type from permalink structure
- Add “page-a” slug to category link if user visit category link from “page-a”
- WordPress Permalinks & Nginx Rewrite Rule Not Working
- Rewrite rule for a query string
- Need to add trailing slash to all internal links relative and absolute
- Get the url of a page template without using the page slug and ID
- How to rewrite a URL to another rewritten URL without changing the address?
- How can I emulate permalink behaviour on static pages
- Unique one time use URL
- wordpress how to replace url /bar with foo/bar for custom post type
- cannot link a external url, present page url acting as parent url
- Permalinks on Windows IIS not working and web.config breaks site – does wordpress not support windows server now, if so how?
- Exclude single page from permalink rule
- How are WordPress Page URLs affected by permalink settings?
- WordPress pages and posts are redirecting to server IP address instead of domain URL [closed]
- “set_front” => false on custom post type breaks wp_list_categories links [closed]
- replicate url permalink after migrating to wordpress
- Make the blog page a child of another page and rewrite the blog url
- How can I access to the same post-type “page” from multiple different urls?
- Multiple URL rewrite rules and get every prams
- How to add a ‘News’ section to specific posts in WordPress
- append current user-id to all internal permalinks
- No Ones Been Able to Override my WordPress Rewrite Rule Issue!
- Pagination links for taxonomy archive page 404 error on every page except first
- WordPress Pagination Custom Rewrite Rule for Pages
- Change all pages permalinks instead of hierarchical to have id of the page
- Remove/hide a specify category-name from the url
- rewrites and custom links in page need help with add_rewrite_rule
- Category-dependent custom permalink
- Imported posts using wrong domain name
- How to create an IIS7 re-write rule for a single category
- Although rewrite engine is on, I get 404 not found on every page
- Customized author slugs not working with get_author_posts_url method
- Using a taxonomy value as part of a post URL
- ?posts_type=xxx not rewritten
- Custom permalink variable on single post
- region selection
- WordPress custom permalinks, pages are now 404
- Creating complex URLs with WordPress permalink structure
- Add additional URL variations for a Post
- Blog posts are not appearing as subs of Blog Page
- Remove parent product category slug from product_cat url woocommerce
- How to make my custom permalink pull up the correct post