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 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
- Change the custom post type permalink
- Auto 301 to full post permalink? (using /posts/%post_id%/%postname%)
- Image Attachment Url Rewrite
- Rewrite Page with a slug before page name
- Can two products with the same name but different category produce unique URLs?
- 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
- remove sub-category of Custom Post Type from permalink structure
- WordPress Permalinks & Nginx Rewrite Rule Not Working
- 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
- Passing the JQuery string to Worldpress URL
- Format HTTP links
- Change directory url to be same as page permalink?
- Edit permalink for certain pages
- Adding URL prefix for foreign language support
- Two URLs of one post is available
- 404 permalink errors on Pages only
- WP-e-commerce (getshopped) – Annoying permalink issue [closed]
- IIS7.5 URL rewrite pboblem on index page
- How to set add_query_arg properly for home page?
- How to redirect old permalinks from https://exmaple.com/category/post_id to https://exmaple.com/category/post_id.html
- Make a post inaccessible without a unique ID in the URL
- A different permalink structure for different categories
- Create different permalinks for same post
- Why does one of my pages not have the option to edit the link?
- Permalink not changing according to post type
- WP permalink working, but why content doesn’t display
- Giving specific category posts its own permalink structure returns 404
- Flushing rewrite rules enables to see an article, but I didnt change anything
- Redirect page to homepage, keeping URL
- Adding query string to multiple page urls in a WordPress function
- Post links broken after migration
- I have Akamai pointing to a WordPress installation with a different URL. Is there a way to make WordPress use this for link generation?
- How can I put WordPress in a directory but keep just the home page at the domain root?
- Prevent Archive URLs
- Updates all internal links on permalink update
- how to have same rewrite rules for 2 different post type?
- What permastrusture tags are generated out of the box right after creating custom post types and taxonomies?
- How to rewrite a folder in WordPress?
- Difference and usage of uri (e.g. get_directory_uri) and absolute path (e.g. get_directory)
- Custom post type with parent page? Possible?
- Folder Name and Category Name WordPress
- Issues with WordPress permalinks
- How to display post permalinks instead of pages?
- Why is there a # and other characters in URL for WordPress site?
- Update permalinks after domain change
- How to change pagination base from slash to query form?
- How to avoid duplicate Url for the home page
- How to shorten the Permalink after WP>WP blog import?
- Removing parent page in URL for one page
- Single product link in woocomerce
- URL issues with WordPress
- Standard Htaccess directives disappear by themselves
- Blog URL Structure – Multiple Taxonomies
- Display the content of another page from a specific URL
- Allow question marks (?) in WordPress permalinks